subscribe method
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(String key, EventHandler<T> handler) {
if (handler is! EventHandler<T>) {
throw ArgumentError('a handler must be specified');
}
// instantiate handlers if required
// _handlers ??= new Map<String, EventHandler<T>>();
if (_handlers.containsKey(key)) print("You've already subscribed using the following key : " + key);
_handlers[key] = (handler);
}