mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
move waitFor and get to BaseObservableValue
This commit is contained in:
parent
b8dcb249ff
commit
514095da7a
@ -25,6 +25,17 @@ export class BaseObservableValue extends BaseObservable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get() {
|
||||||
|
throw new Error("unimplemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
waitFor(predicate) {
|
||||||
|
if (predicate(this.get())) {
|
||||||
|
return new ResolvedWaitForHandle(Promise.resolve(this.get()));
|
||||||
|
} else {
|
||||||
|
return new WaitForHandle(this, predicate);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WaitForHandle {
|
class WaitForHandle {
|
||||||
@ -81,14 +92,6 @@ export class ObservableValue extends BaseObservableValue {
|
|||||||
this.emit(this._value);
|
this.emit(this._value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waitFor(predicate) {
|
|
||||||
if (predicate(this.get())) {
|
|
||||||
return new ResolvedWaitForHandle(Promise.resolve(this.get()));
|
|
||||||
} else {
|
|
||||||
return new WaitForHandle(this, predicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tests() {
|
export function tests() {
|
||||||
|
@ -31,7 +31,7 @@ export class OnlineStatus extends BaseObservableValue {
|
|||||||
this.emit(true);
|
this.emit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
get value() {
|
get() {
|
||||||
return navigator.onLine;
|
return navigator.onLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user