Hi folks,
I have been involved in the Ekon 24 conference and I held a session: Decoupling your application architecture using Delphi Event Bus. There I presented the 2.0 version of DEB and all the news along with this version:
- Added new Interface based mechanism to declare and handle events
- Added channels for simple string-based events
- DEB available on GetIt
Interface based mechanism
The new mechanism relies on the fact that an event must be an interface or its descendants:
This new architecture brings a great benefit in terms of memory management, because Interfaces are reference counted in Delphi.
Breaking changes
- Differently from the previous versions a subscriber method can only have 1 parameter that is an IInterface or descendants.
- You should change every Subscriber method to be compliant with that principle
- On the same line of the previous one, because events now are interfaces EventBus.Post method can accept only an interface as parameter now
- You should change every EventBus.Post method and pass it an interface - if you were using object with no interfaces
Channels
A very nice addition is the possibility to subscribe and post simple string-based events:
Other improvements
- Improved the internal post mechanism removing the CloneEvent due to the fact events were objects
- Removed external sources needed because of the point above
How can I get it?
Since the version 1.5 Delphi Event Bus is available in GetIt (the Delphi integrated package manager):
You can also choose to download/copy/fork the library from github: https://github.com/spinettaro/delphi-event-bus
or downloading directly the release from here: https://github.com/spinettaro/delphi-event-bus/releases/tag/v2.0
Hope you find this version full of interesting features for you!
Enjoy it!!