Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

downdrown/eventrouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

EventRouter

Tiny, lightweight eventing engine.

What?

EventRouter is designed to be a lightweight "Event-Bus-Like" construct that provides a simple and user-friendly api to simplify event-driven architectures. It was designed to work with small to medium size projects, altough it might work well with larger projects too .

Why?

Simple. It is really really easy to use:

final EventRouter eventRouter = new EventRouter();
eventRouter.on(MyEventType.class, event -> doSomething());
eventRouter.trigger(new MyEventType());

done.

The above code sample adds a Callback<MyEventType> to the eventRouter and triggers it afterwards. Since you can add Callbacks and trigger Events from anywhere in your codebase it makes it pretty easy to couple several components or even modules with this mechanism.

How?

You simply instantiate a EventRouter and keep this instance for as long as the bus should be alive. The method EventRouter#on returns you a Registration which lets you unregister the Callback easily using the Registration#unregister method.

If you have a closer look at the EventRouter#on method, you'll see that the first parameter is the type, or to be more specific, the class of the event you want to observe. The second parameter is the Callback which get's triggered when an event of the specified type gets triggerd - typically a lambda expression which represents the passed Event instance.

Samples

If you are looking for some code samples have a look on the EventRouterTest Unit-Test.

Built With

  • Maven - Dependency Management

Versioning

I use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

About

Tiny, lightweight eventing engine.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages