246
247
public beginUpdate<T>(_observable: IObservable<T>): void {
249
throw new BugIndicatingError('Cyclic deriveds are not supported yet!');
250
}
252
>
this._updateCount++;
253
>
this._isUpdating = true;
254
>
try {
255
>
const propagateBeginUpdate = this._updateCount === 1;
256
>
if (this._state === DerivedState.upToDate) {
257
>
this._state = DerivedState.dependenciesMightHaveChanged;
258
>
// If we propagate begin update, that will already signal a possible change.
259
>
if (!propagateBeginUpdate) {
260
for (const r of this._observers) {
261
r.handlePossibleChange(this);
262
}
263
}
265
>
if (propagateBeginUpdate) {
266
>
for (const r of this._observers) {
267
>
r.beginUpdate(this); // This signals a possible change
268
>
}
269
>
}
270
>
} finally {
271
>
this._isUpdating = false;
272
>
}
273
>
}
274
275
public endUpdate<T>(_observable: IObservable<T>): void {
277
>
if (this._updateCount === 0) {
278
>
// End update could change the observer list.
279
>
const observers = [...this._observers];
280
>
for (const r of observers) {
281
>
r.endUpdate(this);
282
>
}
283
>
if (this._removedObserverToCallEndUpdateOn) {
284
const observers = [...this._removedObserverToCallEndUpdateOn];
285
this._removedObserverToCallEndUpdateOn = null;