subscribe method

void subscribe(
  1. EventHandler<T> handler
)

Adds a handler (callback) that will be executed when this Event is raised using the broadcast method.

See also the + shorcut version.

// Example
counter.onValueChanged.subscribe((args) => print('value changed'));

Implementation

void subscribe(EventHandler<T> handler) {
  _handlers.add(handler);
}