Actor<M, A>.create constructor

Actor<M, A>.create(
  1. Handler<M, A> createHandler()
)

Creates an Actor that handles messages with the Handler returned by the createHandler function.

Use the of constructor to wrap a function directly.

Implementation

Actor.create(Handler<M, A> Function() createHandler) {
  _validateGenericType();

  final id = _currentId++;
  _actorImpl = ActorImpl.create();

  _actorImpl.spawn(
      _remote, Message(id, _BoostrapData(_actorImpl.sender, createHandler)));

  _answerStream = _actorImpl.answerStream;
  _sender = _waitForRemotePort(id);
}