eventnotifier 1.1.0 eventnotifier: ^1.1.0 copied to clipboard
Broadcasts named events to interested subscribers. When an event occurs, a method (callback) associated with the subscriber is executed.
example/eventnotifier_example.dart
import 'package:eventnotifier/eventnotifier.dart';
// NOTE: EventNotifier is typically 'mixed-in' with a domain model
void main() {
var e = EventNotifier();
e.subscribe('myChange', (_) => print('boom'));
e.subscribe('myChange', (args) => print(args['pi']));
// number of event names
assert(e.count() == 1);
// number of handlers subscribed to the event name
assert(e.count('myChange') == 2);
// indicate that event 'myChange' has occured
// rguments are only required if a subscriber
// expects one or more
e.notify('myChange', {'pi': 3.14159});
// displays ...
// boom
// 3.14159
}