listen method

ActionSubscription listen(
  1. dynamic onData(
    1. T event
    )
)

Supply a callback that will be called any time this ActionV2 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 Function(T event) onData) {
  _listeners.add(onData);
  return ActionSubscription(() => _listeners.remove(onData));
}