Remove boilerplate around dispatcher and settings watchers (#28338)
* Remove boilerplate around dispatcher and settings watchers Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
b8fd98ab3c
commit
2d9982f9f0
36 changed files with 81 additions and 111 deletions
|
@ -45,8 +45,11 @@ export class MatrixDispatcher {
|
|||
|
||||
/**
|
||||
* Removes a callback based on its token.
|
||||
* @param id The token that was returned by `register`.
|
||||
* Can be undefined to avoid needing an if around every caller.
|
||||
*/
|
||||
public unregister(id: DispatchToken): void {
|
||||
public unregister(id: DispatchToken | undefined): void {
|
||||
if (!id) return;
|
||||
invariant(this.callbacks.has(id), `Dispatcher.unregister(...): '${id}' does not map to a registered callback.`);
|
||||
this.callbacks.delete(id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue