SkillAgentSearch skills...

EventSystem

Tiny event system in D using delegates

Install / Use

/learn @WebFreak001/EventSystem
About this skill

Quality Score

0/100

Supported Platforms

Universal

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

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated1y ago
Forks0

Languages

D

Security Score

70/100

Audited on Sep 23, 2024

No findings