333
334
private _ensureReaderValid(): void {
335
>
if (!this._isReaderValid) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); }
derivedImpl.ts
336
>
}
337
338
public readObservable<T>(observable: IObservable<T>): T {
340
>
341
>
// Subscribe before getting the value to enable caching
342
>
observable.addObserver(this);
343
>
/** This might call {@link handleChange} indirectly, which could invalidate us */
344
>
const value = observable.get();
345
>
// Which is why we only add the observable to the dependencies now.
346
>
this._dependencies.add(observable);
347
>
this._dependenciesToBeRemoved.delete(observable);
348
>
return value;
349
>
}
350
351
public reportChange(change: TChange): void {