Description

Super tiny event system using delegates

Package Information

Version1.2.0 (2017-Apr-11)
Repository https://github.com/WebFreak001/EventSystem
Licensepublic domain
CopyrightCopyright © 2015, webfreak
Authorswebfreak
Registered byWebFreak
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

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();

Available versions

1.2.0 1.1.0 1.0.1 1.0.0 ~master