on method

Stream<Object?> on(
  1. String channel
)

Messages on channel from the other isolates. The first call (on any channel) joins the bus. An isolate never gets its own messages.

Implementation

Stream<Object?> on(String channel) {
  if (_inbox == null) {
    ReceivePort inbox = ReceivePort()..listen(_onInbox);
    _inbox = inbox;
    _send(<Object>['join', _id, inbox.sendPort]);
  }
  return _channels
      .putIfAbsent(channel, StreamController<Object?>.broadcast)
      .stream;
}