UNPKG

snow-falls

Version:

The snow falls and the wind blows

17 lines (14 loc) 297 B
export default class Event<T> { private events = new Set<(evt: T) => void>(); constructor() {} add(fn: (evt: T) => void) { this.events.add(fn); return () => this.events.delete(fn); } run(evt: T) { this.events.forEach((fn) => { fn(evt); }); return true; } }