https://github.com/lmbelo/naturalmulticast
Delphi multicast events implementation without generics
https://github.com/lmbelo/naturalmulticast
delphi events multicast natural
Last synced: 4 months ago
JSON representation
Delphi multicast events implementation without generics
- Host: GitHub
- URL: https://github.com/lmbelo/naturalmulticast
- Owner: lmbelo
- Created: 2019-07-11T14:19:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-23T19:22:37.000Z (almost 3 years ago)
- Last Synced: 2025-05-29T14:21:54.465Z (about 1 year ago)
- Topics: delphi, events, multicast, natural
- Language: Pascal
- Homepage:
- Size: 50.8 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Natural Multicast Events
Natural Multicast Events have been done to be... natural!
It is still Beta, but you can full-feel its power.
It is simple, but powerfull:
1) Naturally add listeners to any event, even already signed events;
2) Any event property can be extended naturaly to multicast;
3) Anonymous listeners are supported;
4) The multicast container is managed by the library itself;
5) Events assigned in the dfm of a form will be called first;
> First thing is to add the Natural.Multicast unit to the uses section of your unit.
```
uses
Natural.Multicast;
```
> Create any class type of your flavor, I'd be using a Form, for instance.
```
TForm1 = class(TForm)
end;
var
Form1 := TForm1.Create(nil);
```
> You can assign a local event method or not.
```
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
//I'm the local event that will be called first!
end;
```
> Create a listener class and start listening to events.
```
TListener = class
public
procedure OnShow(Sender: TObject);
end;
LListener := TListener.Create();
Form1.AddListener('OnShow', LListener.OnShow);
```
> Or else, listen with an anonymous listener
```
Form1.AddListener('OnShow',
procedure(const ASelf: TObject; const AArgs: TArray)
begin
//Notified by Form1 OnShow event
end);
```
#### That is all you need! Very natural...