move waitFor and get to BaseObservableValue
This commit is contained in:
parent
b8dcb249ff
commit
514095da7a
2 changed files with 12 additions and 9 deletions
|
@ -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 {
|
||||
|
@ -81,14 +92,6 @@ export class ObservableValue extends BaseObservableValue {
|
|||
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() {
|
||||
|
|
|
@ -31,7 +31,7 @@ export class OnlineStatus extends BaseObservableValue {
|
|||
this.emit(true);
|
||||
}
|
||||
|
||||
get value() {
|
||||
get() {
|
||||
return navigator.onLine;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue