isolatengine 0.0.1 copy "isolatengine: ^0.0.1" to clipboard
isolatengine: ^0.0.1 copied to clipboard

outdated

isolate communication engine.

Usage #

void _entry(SendPort sendPort) async {
  final receivePort = ReceivePort();
  final engine = Isolatengine(receivePort, sendPort);
  engine['ping'] = (param, {cancelable, notify}) async {
    //debugPrint('ping');
    final stream = Stream.fromIterable(['1/3', '2/3', '3/3']);
    final ctrl = StreamController();
    cancelable?.whenCancel(() {
      ctrl.close();
    });
    ctrl.stream.take(3).listen((event) {
      notify?.call(event);
    });
    ctrl.addStream(stream, cancelOnError: true);
    await ctrl.done;
    return 'pong';
  };
  await engine.receive();
}

void main(){
    final receivePort = ReceivePort();
    final engine = Isolatengine(receivePort);
    Timer.periodic(const Duration(seconds: 5), (timer) async {
      try {
        final cancelable = Cancelable();
        final replication = await engine.deliver('ping', cancelable: cancelable, notify: (param) {
          //debugPrint(param);
        });
        //debugPrint(replication);
      } catch (e) {
          //debugPrint(e);
      }
    });
    await Isolate.spawn(_entry, receivePort.sendPort);
    await engine.receive();
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

isolate communication engine.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cancelable, flutter

More

Packages that depend on isolatengine