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

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

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

4. Fire Events 🔥 #

Create an instance of your Event class and use fire.


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

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
130
pub points
79%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

meta

More

Packages that depend on event_taxi