party_bus 1.0.0
party_bus: ^1.0.0 copied to clipboard
Party Bus is a simple, naive event bus library oriented for DDD and CQRS.
Party Bus is a simple, naive event bus library oriented for DDD and CQRS.
The goal of the library is to be dead simple with a fun name, no shiny parts, no extensive studies how about with leverage that specific instructions or handle edges cases. Plain, simple event emitter / receiver based on dart's Stream.
Ticket, please #
To get started, either add the package to your pubspec.yaml or use the following command:
dart pub add party_bus
Here we go #
This a simple example of how to use the library:
import 'package:party_bus/party_bus.dart';
/// An example event
final class MyEvent(final String name);
Future<void> main() async {
/// If you want multiples buses you can use the [PartyBus.named] constructor
final bus = PartyBus();
/// An "event" is any valid dart object
bus.on<MyEvent>().listen((event) {
print('Event received: {$event.name}');
});
/// To write to the bus use add
bus.add(MyEvent(name: 'event'));
/// When done close all the buses
await bus.dispose();
}
Check the example folder for more examples.