dart_saga 0.1.0 copy "dart_saga: ^0.1.0" to clipboard
dart_saga: ^0.1.0 copied to clipboard

outdated

Port of redux-saga to Dart.

[WIP][POC] Port of redux-saga to Dart #

Redux-saga like process manager for Dart.

Note: This package is still under development, and many of functionality might not be available yet. Feedback and Pull Requests are most welcome!

Sample code #

import "dart:async";
import 'package:dart_saga/dart_saga.dart';

Iterable<Effect> rootSaga([msg]) sync* {
  print("rootSaga(${msg}) started");
  yield new ForkEffect(saga2, "start saga2");
  while (true) {
    print("rootSaga");
    yield new AsyncCallEffect.func(
        () => new Future.delayed(new Duration(seconds: 1)));
  }
}

Iterable<Effect> saga2([msg]) sync* {
  print("           saga2(${msg}) started");
  yield new ForkEffect(saga3, "start saga3");
  while (true) {
    print("           saga2");
    yield new WaitEffect(3);
    yield new PutEffect(new Action("HOGE"));
  }
}

Iterable<Effect> saga3([msg]) sync* {
  print("                      saga3(${msg}) started");
  while (true) {
    print("                      saga3");
    yield new TakeEffect(new Action("HOGE"));
  }
}

main() async {
  var effectManager = new EffectManager();
  effectManager.startSaga(rootSaga, "start rootSaga");
}


Demo #

% pub run example/simple_demo.dart
start isolate context
rootSaga(start rootSaga) started
rootSaga
           saga2(start saga2) started
           saga2
                      saga3(start saga3) started
                      saga3
rootSaga
rootSaga
rootSaga
           saga2
Action(HOGE)
                      saga3
rootSaga
rootSaga
  :
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Port of redux-saga to Dart.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on dart_saga