This commit is contained in:
Martin
2022-11-16 12:26:20 +01:00
parent 3dd10f13ef
commit 0eb9cc907f
23 changed files with 1312 additions and 485 deletions

View File

@@ -17,8 +17,12 @@ export class Signal<T> implements ISignal<T> {
}
public trigger(data: T): void {
for (let i = 0; i < this.handlers.length; i++) {
this.handlers[i].call(this.thisArgs[i], data);
// protect from trigger >> off
const handlers: ((data: T) => void)[] = [...this.handlers];
const thisArgs: any[] = [...this.thisArgs];
for (let i = 0; i < handlers.length; i++) {
handlers[i].call(thisArgs[i], data);
}
}
}