publish method

  1. @override
void publish(
  1. Message message
)
override

Publishes a message to be received by any subscribers.

If there are no subscripbers to the messange name, this method will do nothing.

Implementation

@override
void publish(Message message) {
  if (message == null) {
    throw ArgumentError('A message must be provided.');
  }

  if (_messengers.any((m) => m.name == message.name)) {
    var messenger = _messengers.singleWhere((m) => m.name == message.name);
    messenger.streamController.add(message.parameter);
  }
}