listen method

ActionSubscription listen (dynamic onData(T event))

Supply a callback that will be called any time this Action is dispatched. A payload of type T will be passed to the callback if supplied at dispatch time, otherwise null will be passed. Returns an ActionSubscription which provides means to cancel the subscription.

Implementation

ActionSubscription listen(dynamic onData(T event)) {
  _listeners.add(onData);
  return new ActionSubscription(() => _listeners.remove(onData));
}