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:
Michael Telatynski
2024-11-01 15:15:04 +00:00
committed by GitHub
parent b8fd98ab3c
commit 2d9982f9f0
36 changed files with 81 additions and 111 deletions

View File

@@ -192,10 +192,11 @@ export default class SettingsStore {
/**
* Stops the SettingsStore from watching a setting. This is a no-op if the watcher
* provided is not found.
* @param {string} watcherReference The watcher reference (received from #watchSetting)
* to cancel.
* @param watcherReference The watcher reference (received from #watchSetting) to cancel.
* Can be undefined to avoid needing an if around every caller.
*/
public static unwatchSetting(watcherReference: string): void {
public static unwatchSetting(watcherReference: string | undefined): void {
if (!watcherReference) return;
if (!SettingsStore.watchers.has(watcherReference)) {
logger.warn(`Ending non-existent watcher ID ${watcherReference}`);
return;