eventnotifier 1.1.1 copy "eventnotifier: ^1.1.1" to clipboard
eventnotifier: ^1.1.1 copied to clipboard

discontinuedreplaced by: event

An implementation in Dart of an 'Event Bus' or 'Event Broker'. 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
}
0
likes
20
pub points
0%
popularity

Publisher

verified publisheraryehoffman.com

An implementation in Dart of an 'Event Bus' or 'Event Broker'. Broadcasts named events to interested subscribers. When an event occurs, a method (callback) associated with the subscriber is executed.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on eventnotifier