dart_saga 0.3.0

  • README.md
  • Installing
  • Versions
  • 44

[WIP][poc] Port of redux-saga to Dart

Redux-saga like process manager for Dart.

This library supports communication pattern between isolates through 'cannel'.

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';

rootSaga([msg, greeting]) async* {
  print("rootSaga(${msg}) started greeting: ${greeting}");
  Completer<int> saga2handle = new Completer();
  yield fork(saga2, params: ["start saga2"], completer: saga2handle);

  for (int i = 0; i < 10; i++) {
    yield wait(1);
    if (i == 5) {
      yield cancel(await saga2handle.future);
    }
  }
}

saga2([msg]) async* {
  print("           saga2(${msg}) started");
  Completer<int> saga3handle;
  yield fork(saga3, params: ["start saga3"], completer: saga3handle);

  for (int i = 0; true; i++) {
    print("           saga2");
    yield wait(1);
    yield put(Action("HOGE", "From saga2"));
    if (i == 3) {
      yield cancel(await saga3handle.future);
    }
  }
}

saga3([msg]) async* {
  print("                      saga3(${msg}) started");
  while (true) {
    print("                      saga3");
    Completer takenAction = new Completer();
    yield take("HOGE", completer: takenAction);
    print("                      taken ${await takenAction.future}");
  }
}

main() {
  var effectManager = new EffectManager();
  effectManager.run(rootSaga, ["start rootSaga", "hello"]);
}

Demo

% pub run example/simple_demo.dart
start _isolate context
Task.start 0
rootSaga(start rootSaga) started greeting: hello
Task.start 1
           saga2(start saga2) started
           saga2
Task.start 2
                      saga3(start saga3) started
                      saga3
           saga2
                      taken Action(HOGE, From saga2)
                      saga3
           saga2
                      taken Action(HOGE, From saga2)
                      saga3
           saga2
                      taken Action(HOGE, From saga2)
                      saga3
Task(taskId=2) terminated: null.
Task(taskId=1) terminated: null.
Task(taskId=0) terminated: null.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_saga: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_saga/dart_saga.dart';
  
Version Uploaded Documentation Archive
0.3.0 May 18, 2018 Go to the documentation of dart_saga 0.3.0 Download dart_saga 0.3.0 archive
0.2.0 May 15, 2018 Go to the documentation of dart_saga 0.2.0 Download dart_saga 0.2.0 archive
0.1.0 Apr 12, 2018 Go to the documentation of dart_saga 0.1.0 Download dart_saga 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
6
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:dart_saga/dart_saga.dart with components: isolate.

Health suggestions

Fix lib/dart_saga.dart. (-3.45 points)

Analysis of lib/dart_saga.dart reported 7 hints, including:

line 18 col 7: Name types using UpperCamelCase.

line 22 col 7: Name types using UpperCamelCase.

line 26 col 7: Name types using UpperCamelCase.

line 30 col 7: Name types using UpperCamelCase.

line 35 col 7: Name types using UpperCamelCase.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use dart_saga.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.32.0 <3.0.0