EventManager

final
class EventManager (
T...
) {}

Examples

1 auto event = new EventManager!int();
2 
3 int sum;
4 auto tag1 = event.strongConnect(delegate(a){ sum += a; });
5 
6 event.emit(12);
7 assert(sum == 12);
8 
9 auto tag2 = event.strongConnect(() { sum += 2; });
10 
11 event.emit(4);
12 assert(sum == 18);  // add 2 + 4
13 
14 event.disconnect(tag1);
15 event.emit(12);
16 assert(sum == 20);  // only add 2
17 
18 event.disconnect(tag2);
19 event.emit(5);
20 assert(sum == 20);

Meta