typed_event_bus

Creator: coderz1093

Last updated:

0 purchases

typed_event_bus Image
typed_event_bus Images
Add to Cart

Description:

typed event bus

typed_event_bus #
Simple event bus with typed event and subscription chain
Usage #
To use this plugin, add typed_event_bus as a dependency in your pubspec.yaml file.
Example #
import 'package:typed_event_bus/typed_event_bus.dart';

class TestEvent {}

class TestDataEvent {
final String message;

TestDataEvent(this.message);
}

void main() {
final bus = TypedEventBus();

final subscription = bus.onEvent<TestEvent>((_) {
print('Catch only TestEvent data');
}).onEvent<TestDataEvent>((data) {
print('Catch only TestDataEvent data');
print('With message ${data.message}')
});

bus.emit<TestEvent>(TestEvent());
bus.emit(TestDataEvent('from'));

subscription.dispose();
bus.dispose();
}
copied to clipboard
License #
The MIT License (MIT)

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.