|
|
@ -16,13 +16,13 @@ export class BroadcastController extends Controller { |
|
|
|
this._broadcasts[name] = []; |
|
|
|
this._broadcasts[name] = []; |
|
|
|
} |
|
|
|
} |
|
|
|
this._broadcasts[name].push(fn); |
|
|
|
this._broadcasts[name].push(fn); |
|
|
|
|
|
|
|
|
|
|
|
return () => this.remove(name, fn); |
|
|
|
return () => this.remove(name, fn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
send(name) { |
|
|
|
send(name) { |
|
|
|
const args = [].slice.call(arguments, 1); |
|
|
|
const args = [].slice.call(arguments, 1); |
|
|
|
each(this._broadcasts[name], (i, fn) => fn(...args)); |
|
|
|
each(this._broadcasts[name]?.slice?.(), (i, fn) => fn(...args)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
remove(name, fn) { |
|
|
|
remove(name, fn) { |
|
|
@ -34,7 +34,7 @@ export class BroadcastController extends Controller { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
delete this._broadcasts[name]; |
|
|
|
delete this._broadcasts[name]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|