forked from MapComplete/MapComplete
Refactoring: mark UIEventSource as a svelte-writable
This commit is contained in:
parent
e9797fbd39
commit
74dd9974ca
1 changed files with 10 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { Utils } from "../Utils"
|
import { Utils } from "../Utils"
|
||||||
import { Readable, Subscriber, Unsubscriber } from "svelte/store"
|
import { Readable, Subscriber, Unsubscriber, Updater, Writable } from "svelte/store"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various static utils
|
* Various static utils
|
||||||
|
@ -542,7 +542,7 @@ class MappedStore<TIn, T> extends Store<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UIEventSource<T> extends Store<T> {
|
export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
||||||
public data: T
|
public data: T
|
||||||
_callbacks: ListenerTracker<T> = new ListenerTracker<T>()
|
_callbacks: ListenerTracker<T> = new ListenerTracker<T>()
|
||||||
|
|
||||||
|
@ -786,4 +786,12 @@ export class UIEventSource<T> extends Store<T> {
|
||||||
(b) => "" + b
|
(b) => "" + b
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set(value: T): void {
|
||||||
|
this.setData(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
update(f: Updater<T> & ((value: T) => T)): void {
|
||||||
|
this.setData(f(this.data))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue