I have just started a new open source project: Delphi Event Bus a.k.a. DEB. As the title suggest DEB is an event bus framework based on publish/subscribe mechanism. It was inspired by EventBus framework for the Android platform.
How it works
DEB is designed to decouple different parts/layers of your application while still allowing them to communicate efficiently. The really exciting feature of this framework is that you can choose the delivery mode of the events: in the Main Thread or a Background thread.Simply put the Subscribe attribute on your subscriber method you are able to receive a specific event, and by specifying the TThreadMode in attribute you can choose the context where to deliver the event.
For example, if you have to interact with the UI EventBus can deliver events in the main thread or If your subscriber does long running tasks (HTTP request), EventBus can also use background threads to avoid UI blocking. Regardless where an event was posted the EventBus will manage Thread synchronization, so you can deliver an Event in the MainThread and the subscriber will receive it on a background thread and viceversa.
Show me the code
Support
- DEB is a 100% ObjectPascal framework so it works on VCL and Firemonkey
- It works with DelphiXE7 and major
- It should be works fine also on AppMethod
Currently, the project consists in a simple getting started guide, 2 great samples and a suite of unit tests. There is a lot of work to do, so any contributor is welcome. The project is hosted on github and here there is the link. I hope you are excited as much as I am about this project!
Stay tuned!