eventsystem

Super tiny event system using delegates


Keywords
library
License
Unlicense
Install
dub fetch eventsystem --version 2.0.0

Documentation

Tiny Event System

Its just 35 lines of code + unittests and it supports regular events & cancelable events!

Usage:

import tinyevent;

// Regular event
Event!string onStringChange;
static assert(isEvent!onStringChange);
static assert(isEmittable!onStringChange);
onStringChange ~= (str) { /* Handle new string */ };
onStringChange.emit("Foo");
import tinyevent;

// Cancelable
Cancelable!bool onQuit;
static assert(isCancelable!onQuit);
static assert(isEmittable!onQuit);
onQuit ~= (force) { return force || !saved; }

// When pressing X:
if(!onQuit.emit(false))
	showUnsavedChangesDialog();
else
	exit();