event_taxi 0.1.5

Dart native js
Flutter Android iOS web

A starting point for Dart libraries or applications.

example/event_taxi_example.dart

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;

  UserLoggedIn({this.username});
}

main() {
  EventTaxi eventBus = EventTaxiImpl();

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

  eventBus.fire(TodoCreated(
      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"
    print(event.username);
  });

  eventBus.fire(UserLoggedIn(username: "Tobi"));
}
3
likes
90
pub points
85%
popularity

A starting point for Dart libraries or applications.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

sschaller00@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

meta

More

Packages that depend on event_taxi