IsolateWorker<A, S> constructor

IsolateWorker<A, S>()

Implementation

IsolateWorker() {
  _stateSubscription = _controller.stream
    .where((event) => event is IsolateWorkerStateEvent<S>)
    .cast<IsolateWorkerStateEvent<S>>()
    .listen((nextState) {
      _state = nextState.state;
      for(final completer in _stateCompleters) {
        completer.complete(_state);
        _stateCompleters.remove(completer);
      }
    });

  _inActionSubscription = _controller.stream
    .where((event) => event is IsolateWorkerInActionEvent<A>)
    .cast<IsolateWorkerInActionEvent<A>>()
    .listen((event) {
      execute(event.action);
    });
}