also make an observable version of a retained value

This commit is contained in:
Bruno Windels 2021-05-07 13:06:20 +02:00
parent 36f54420cf
commit 3143f2a791

View file

@ -94,6 +94,18 @@ export class ObservableValue extends BaseObservableValue {
} }
} }
export class RetainedObservableValue extends ObservableValue {
constructor(initialValue, freeCallback) {
super(initialValue);
this._freeCallback = freeCallback;
}
onUnsubscribeLast() {
super.onUnsubscribeLast();
this._freeCallback();
}
}
export function tests() { export function tests() {
return { return {
"set emits an update": assert => { "set emits an update": assert => {