sharpevents 2.0.0
Library that adds C#-esque events to D.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
sharpevents
Library that adds C#-esque events to D.
Events
An Event(T)
is a container for a collection of delegate callbacks. T
is the data type you want to pass to callbacks.
import events;
struct MyEventData {
int callbackIntValue;
}
void main() {
Event!MyEventData event = new Event!MyEventData;
// The function signature that the event accepts in this case is:
// void delegate(void*, MyEventData)
event ~= (sender, args) {
import std.stdio : writeln;
writeln(args.callbackIntValue);
};
// Pass a null sender and MyEventData to the event.
event(null, MyEventData(42));
// Remove all handlers from the event
event.clear();
// If you have an instance of the handler available you can also remove a single instance via
// event -= (handler);
}
Basic Events
Basic events are a bit more like C# events, the event arguments are based of a EventArgs class. But the implementation is slightly limited.
See the unittests in events/event.d
- Registered by Clipsey
- 2.0.0 released 4 years ago
- PolyplexEngine/sharpevents
- Boost
- Copyright © 2018, Clipsey
- Authors:
- Dependencies:
- none
- Versions:
-
2.0.0 2020-Feb-27 1.0.2 2018-May-13 1.0.1 2018-Mar-15 1.0.0 2018-Feb-27 ~master 2020-Feb-27 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
185 downloads total
-
- Score:
- 0.8
- Short URL:
- sharpevents.dub.pm