event_taxi 1.0.0 copy "event_taxi: ^1.0.0" to clipboard
event_taxi: ^1.0.0 copied to clipboard

EventTaxi could be used to send events through different layers of the application decoupled from the architecture.

EventTaxi #

Pattern #

An EventBus follows the publish/subscribe pattern. It allows listeners to subscribe for events and publishers to fire events. This enables objects to interact without requiring to explicitly define listeners and keeping track of them.

Event Taxi in Flutter Apps or Angular Web Apps #

This EventBus is perfect for decoupling different layers from each other. Besides the standard functionality provided by EventBus, it appends small additional features that we are using in our products.

Usage #

1. Create the Event Taxi 🚕 #

import 'package:event_taxi/event_taxi.dart';

// new instance
EventTaxi eventTaxi = EventTaxiImpl();

// singleton instance if preferred
EventTaxi eventTaxi = EventTaxiImpl.singleton();
copied to clipboard

Note: The EventTaxi is always a singleton

2. Define Events 📦 #

Every event has to be a sub class of Event. Those classes can hold additional information if needed.

class RefreshDataEvent implements Event {
  // additional information
  final DateTime requestTime;
  final String fetchedJson;
}
copied to clipboard

3. Register Listeners 🎧 #

Simply call register to get a stream of events. true will create a stream that immediately emits the last event as well. (Similar to a BehaviourSubject in RxDart.)


eventBus.registerTo<RefreshDataEvent>(true).listen((event) {
    // handle event
  });

copied to clipboard

4. Fire Events 🔥 #

Create an instance of your Event class and use fire.


var event = RefreshDataEvent();
eventBus.fire(event);

copied to clipboard

License #

The Apache License Version 2.0 (Check the LICENCE file in this repository)

Features and bugs #

Please file feature requests and bugs at the issue tracker.

7
likes
150
points
489
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.19 - 2025.04.03

EventTaxi could be used to send events through different layers of the application decoupled from the architecture.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

meta

More

Packages that depend on event_taxi