refactor(utils.ts): add parameter arg0 to addWatcher callback for improved readability

This commit is contained in:
Sped0n
2023-11-02 12:27:58 +08:00
parent 8b48cceb8f
commit dd01dd8bec
5 changed files with 14 additions and 14 deletions

View File

@@ -42,7 +42,7 @@ export function onVisible<T extends Element>(
export class Watchable<T> {
constructor(private obj: T) {}
private readonly watchers: Array<() => void> = []
private readonly watchers: Array<(arg0: T) => void> = []
get(): T {
return this.obj
@@ -51,11 +51,11 @@ export class Watchable<T> {
set(e: T): void {
this.obj = e
this.watchers.forEach((watcher) => {
watcher()
watcher(this.obj)
})
}
addWatcher(watcher: () => void): void {
addWatcher(watcher: (arg0: T) => void): void {
this.watchers.push(watcher)
}
}