subscribe<T> method

dynamic subscribe<T>(
  1. String topic,
  2. EventHandler<T> handler
)

Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler

  • topic The topic to subscribe to
  • handler The event handler

Implementation

subscribe<T>(String topic, EventHandler<T> handler) {
  if (_callbackMaps[topic] == null) {
    _callbackMaps[topic] = [].cast<EventHandler<T>>();
  }
  List<EventHandler<T>> handlers = _callbackMaps[topic];
  handlers.add(handler);
}