Skip to content

iadept/typed_event_bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();
}

License

The MIT License (MIT)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages