Clipsey 3c0989d834 fixed a language mistake 5 months ago
source/sev/event fixed a language mistake 5 months ago
.gitignore Fixed .gitignore mishap 9 months ago
LICENSE sharpevents is now boost licensed 6 months ago
README.md Update 'README.md' 6 months ago
dub.json Update dub.json 7 months ago

README.md

sharpevents

Library that adds C#-esque events to D.

How to use

import sev to use the Event and EventArgs classes.

To create a new event, do like this.

public Event MyNewEvent = new Event();

An event handler has the signature of void name

public void MyEventHandler (void* sender, EventArgs args) {
	//Do something.
}

Subscribe to an event by doing ~= (or += like in C#). Remember to use a pointer to the handler.

MyNewEvent ~= &MyEventHandler;
// You can also do this, if you are more used to the C# method.
MyNewEvent += &MyEventHandler;

To unsubscribe, use -=

MyNewEvent -= &MyEventHandler;

To invoke subscribed event handlers, run the class instance like a function. Remember to specify sender and arguments (cast to void*)

MyNewEvent(null, null);

Donations

If this small library has been of any help to you, consider Donating. c: