isEmittable

Returns true if the type or variable is an Event or Cancelable

enum bool isEmittable(T);

Examples

Event!string onStringChange;
static assert (isEvent!(typeof(onStringChange)));
static assert (!isCancelable!(typeof(onStringChange)));
static assert (isEmittable!(typeof(onStringChange)));
onStringChange ~= (s) { assert(s == "Foo"); };
onStringChange.emit("Foo");
Cancelable!int onIntChange;
static assert (!isEvent!(typeof(onIntChange)));
static assert (isCancelable!(typeof(onIntChange)));
static assert (isEmittable!(typeof(onIntChange)));
int changed = 0;
onIntChange ~= (i) { if(i > 5) return false; changed++; return true; };
onIntChange ~= (i) { if(i > 4) return false; changed++; return true; };
onIntChange ~= (i) { if(i > 3) return false; changed++; return true; };
assert(onIntChange.emit(2));
assert(changed == 3);

changed = 0;
assert(!onIntChange.emit(4));
assert(changed == 2);

Meta