emitParams method

void emitParams(
  1. String topic,
  2. CallbackParams args
)

Emits an event with the given topic and args to all subscribed callbacks.

This method retrieves the list of callbacks subscribed to the given topic, then calls each callback with the given args using the Function.apply method.

Additionally, this method retrieves the list of callbacks that were subscribed once to the given topic, calls each callback with the given args, and then removes them from the list of once-subscribed callbacks.

If no callbacks are found for the given topic, this method does nothing.

Implementation

void emitParams(String topic, CallbackParams args) {
  void _send(Function? fn) =>
      Function.apply(fn!, args.positional, args.named);
  _cache[topic]?.forEach(_send);
  _cacheOnce[topic]?.forEach(_send);
  _cacheOnce.remove(topic);
}