zam_event_bus 0.2.0 copy "zam_event_bus: ^0.2.0" to clipboard
zam_event_bus: ^0.2.0 copied to clipboard

outdated

Event bus is a event based state management package for dart.

Event Bus #

A State Management Package for flutter.

Use it in conjunction with zam_event_bus_provider.

Version Build Stars License

What's inside the package #

Includes the following core components.

Check out all the components in detail here

How to use #

INFO: For flutter usage and providing EventBus to widgets, checkout the zam_event_bus_provider package.

Step 1: Create the bus #

final bus = EventBus([
  EventTransformer(HeightSliderDraggedEvent, (event) => HeightProvidedEvent(event.value)),
  EventTransformer(HeightInputTextChangedEvent, (event) => HeightProvidedEvent(event.value)),
  EventTransformer(WeightSliderDraggedEvent, (event) => WeightProvidedEvent(event.value)),
  EventTransformer(WeightInputTextChangedEvent, (event) => WeightProvidedEvent(event.value)),
  EventTransformer(HeightProvidedEvent, (event) => Bmi.fromHeight(event.value)),
  EventTransformer(WeightProvidedEvent, (event) => Bmi.fromWeight(event.value)),
]);

Step 2: Publish Events #

bus.publish(HeightSliderDraggedEvent(1.78));

Step 3: Select Events #

final sub = bus.select<Bmi>().listen((event) => print(event.value)); // prints bmi value

Step 4: Dispose the bus #

await sub.cancel();
await bus.dispose();

To learn more, move on to the example section or check out this dedicated example in github.

Contributors #

0
likes
0
pub points
17%
popularity

Publisher

verified publisherzamstation.com

Event bus is a event based state management package for dart.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

zam_command_pattern, zam_core

More

Packages that depend on zam_event_bus