Does an implementation of the signals and slots mechanism for event dispatching exist for Delphi?
Signals and slots implementation in Delphi?
Asked Answered
Non-multicast event handling is built in. It's just the multicast part that needs add-ons. –
Anacoluthia
I added a mixup of the suggested methods at bitbucket.org/MX4399/multicast-events-using-generics –
Gamba
Search for multicast events. There are a few implementations out there, e.g.
- http://www.deltics.co.nz/blog/?p=137
- http://blogs.embarcadero.com/abauer/2008/09/03/38867
- http://www.codebot.org/delphi/?doc=9568
Some of them need generics, so are D>2009 only.
TApplicationEvents uses eventsink too. –
Willi
@Downvoter: I tried to use TApplicationEvents for my own multicast events once. Unfortunately it's designed mostly un-reuseable, like most of the VCL. :-/ –
Selinski
Whilst you can implement multi-cast events yourself, they are not directly supported in the the language unlike in C# and VB.NET. Lack of language support makes any attempt to emulate multi-cast events rather clumsy.
Interestingly, C++ lacks support for signals and slots and the Qt solution involves an extra process in the compilation tool chain, the Meta Object Compiler.
More importantly, the VCL and the IDE don't support whatever your implementation of multi-cast events is, making it's use clumsy. The language as-is could be used to implement nice multi-cast events, even implement the full-blown registration-free "signals and slots" thing (using RTTI Attributes). Using operator overloading you can almost get C# syntax working. –
Singletree
I spent some time a while ago getting Allen Bauer's Multicast Event code working. It has some limitations, but works well in my code. You can see the code here.
Of course, it only works in Delphi > 2009
The original post from Allen only supported 32 bit. If you are looking for a version that supports 64 bit as well you can find it here: github.com/JensBorrisholt/OnlineOffline –
Rouault
© 2022 - 2024 — McMap. All rights reserved.