flutter_eventemitter2 1.0.0 flutter_eventemitter2: ^1.0.0 copied to clipboard
Dependency free publish/subscribe(pub/sub) for dart&flutter.
eventemitter #
Dependency free publish/subscribe(pub/sub) for dart&flutter.
How to use #
Open the pubspec.yaml
file, and add eventemitter:
unde dependencies:
dependencies:
flutter:
sdk: flutter
# ...
# ...
eventemitter: ^0.1.3
install it from terminal: Run flutter packages get
Example #
String token = EventEmitter.subscribe('topic', (data) {
// receive 2
print(data);
});
// publish is async function
EventEmitter.publish('topic', 1)
EventEmitter.publishSync('topic', 2)
EventEmitter.unsubscribe(token);