4

Does an implementation of the signals and slots mechanism for event dispatching exist for Delphi?

Warren P
  • 65,725
  • 40
  • 181
  • 316
MX4399
  • 1,519
  • 1
  • 15
  • 27
  • Non-multicast event handling is built in. It's just the multicast part that needs add-ons. – Warren P Jul 23 '11 at 22:38
  • 1
    I added a mixup of the suggested methods at https://bitbucket.org/MX4399/multicast-events-using-generics – MX4399 Sep 16 '11 at 10:26

3 Answers3

4

Search for multicast events. There are a few implementations out there, e.g.

Some of them need generics, so are D>2009 only.

Uli Gerhardt
  • 13,748
  • 1
  • 45
  • 83
2

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 1
    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. – Cosmin Prund Jul 22 '11 at 10:05
1

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

Community
  • 1
  • 1
Nat
  • 5,414
  • 26
  • 38
  • 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: https://github.com/JensBorrisholt/OnlineOffline – Jens Borrisholt Sep 30 '18 at 18:39