Giter VIP home page Giter VIP logo

event_bus_plus's Introduction

EventBus: Events for Dart/Flutter

pub package codecov Dart

EventBus is an open-source library for Dart and Flutter using the publisher/subscriber pattern for loose coupling. EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code, removing dependencies, and speeding up app development.

event bus publish subscribe

Your benefits using EventBus: It…

  • simplifies the communication between components;
  • decouples event senders and receivers;
  • performs well with UI artifacts (e.g. Widgets, Controllers);
  • avoids complex and error-prone dependencies and life cycle issues.

event bus plus

Define the app's events

// Initialize the Service Bus
IAppEventBus eventBus = AppEventBus();

// Define your app events
final event = FollowEvent('@devcraft.ninja');
final event = CommentEvent('Awesome package 😎');

Subscribe

// listen the latest event
final sub = eventBus.last$
        .listen((AppEvent event) { /*do something*/ });

// Listen particular event
final sub2 = eventBus.on<FollowAppEvent>()
        .listen((e) { /*do something*/ });

Publish

// fire the event
eventBus.fire(event);

Watch events in progress

// start watch the event till its completion
eventBus.watch(event);

// and check the progress
eventBus.isInProgress<FollowAppEvent>();

// or listen stream to check the processing
eventBus.inProgress$.map((List<AppEvent> events) =>
        events.whereType<FollowAppEvent>().isNotEmpty);

// complete
_eventBus.complete(event);

// or complete with completion event
_eventBus.complete(event, nextEvent: SomeAnotherEvent);

History

final events = eventBus.history;

Mapping

final eventBus = bus = EventBus(
        map: {
          SomeEvent: [
            (e) => SomeAnotherEvent(),
          ],
        },
      );

Contributing

We accept the following contributions:

Maintainers

event_bus_plus's People

Contributors

andrewpiterov avatar bahag-raesenerm avatar hatemragab avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.