Creates an object that will have event slots for each property of the template type T. The caller will be the owner of the event slots; that is, it will be able to fire events and clear all listeners when necessary. This allows the following code:
type IMyEvents ={ click: () => void; change: ( newVal: number) => void;}interface IMyClass{ events: MultiEventSlot<IMyEvents>; doSomething(): void;}class MyClass implements IMyClass{ private _events = createMultiEventSlot<IMyEvents>(); public get events(): MultiEventSlot<IMyEvents> { return this._events; } public doSomething(): void { this._events.change.fire(1);}}let obj: IMyClass = new MyClass();obj.events.change.attach( (n: number) => console.log(n));obj.doSomething();
Creates an object that will have event slots for each property of the template type T. The caller will be the owner of the event slots; that is, it will be able to fire events and clear all listeners when necessary. This allows the following code: