send method

  1. @override
FutureOr<A> send(
  1. M message
)
override

Send a message to the Handler this Actor is based on.

The message is handled in another Isolate and the handler's response is sent back asynchronously.

If an error occurs while the Handler handles the message, the returned Future completes with an error, otherwise it completes with the answer given by the Handler.

Implementation

@override
FutureOr<A> send(M message) {
  final id = _currentId++;
  final futureAnswer = _answerStream.firstWhere((m) => m.id == id);
  _sender.then((s) => s.send(Message(id, message)));
  return handleAnswer(futureAnswer);
}