event_taxi 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 93

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

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.

0.1.5 #

  • Fix README.md

0.1.4 #

  • You can use the eventBus as singleton, or as a normal instance normal (new) instance: EventBusImpl = new EventBusImpl() Singleton: EventBusImpl = EventBusImpl.singleton()

0.1.3 #

  • Update ReadMe.md
  • Fix UnitTests
  • Fix UnitTest name schema
  • Fix Exception from the "registerAll" method.

0.1.2 #

  • Decrease Meta Package Version (Flutter Apps got errors with 1.1.7)

0.1.1 #

  • Add missing export path from event

0.1.0 #

  • Upload to Dart Packages

0.0.1 #

  • Initial version, created by Tikkr
  • Add EventTaxiImpl Class
  • Add EventTaxi Interface (Abstract class)
  • Add EventController
  • Add readMe
  • Add example images for readMe


import 'package:event_taxi/event_taxi.dart';
import 'package:event_taxi/src/event.dart';

class TodoCreated implements Event {
  final String name;
  final String description;

  TodoCreated({this.name, this.description});

class UserLoggedIn implements Event {
  final String username;


main() {
  EventTaxi eventBus = EventTaxiImpl();

  eventBus.registerTo<TodoCreated>().listen((event) {
    // handle event
    print("to created: name=${event.name}, description=${event.description}");

      name: "create example",
      description: "add example for this cool libary called EventTaxi 🚕."));

  // additionally you can also register and immediately receive the previous event
  eventBus.fire((UserLoggedIn(username: "Stefan")));

  eventBus.registerTo<UserLoggedIn>(true).listen((event) {
    // prints "Stefan" and then "Tobi"

  eventBus.fire(UserLoggedIn(username: "Tobi"));

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  event_taxi: ^0.1.5

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:event_taxi/event_taxi.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 25, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/src/event_controller.dart. (-0.50 points)

Analysis of lib/src/event_controller.dart reported 1 hint:

line 30 col 3: Avoid return types on setters.

Format lib/event_taxi.dart.

Run dartfmt to format lib/event_taxi.dart.

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta ^1.1.6 1.1.8
Dev dependencies
test ^1.5.2