Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.value = newResult;
}
else {
isFirst = true;
}
}
catch (err) {
this.exception = err;
this.value = undefined;
}
if (!isFirst)
this.invalidate();
if (alreadyInterrupted)
this.partialResults = true;
this.state = 3 /* Updated */;
b.setCurrentCtx(backupCurrentCtx);
if (this.partialResults) {
this.state = 1 /* NeedRecheck */;
setPartialResults();
}
};
ComputedImpl.prototype.run = function () {
update(): void {
if (alreadyInterrupted && this.partialResults) {
setPartialResults();
return;
}
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.partialResults = false;
this.freeUsings();
let wasChange = false;
if (this.state === ComputedState.First) {
this.state = ComputedState.Updated;
this.value = this.call();
wasChange = true;
} else {
this.state = ComputedState.Updated;
let newResult = this.call();
if (!this.comparator(this.value, newResult)) {
this.value = newResult;
wasChange = true;
}
}
promiseFulfilled(value: any) {
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.state = ComputedState.Updating;
try {
this.iteratorNext(this.iterator!.next(value));
} catch (err) {
this.value = new CaughtException(err);
this.state = ComputedState.Updated;
this.invalidate();
}
b.setCurrentCtx(backupCurrentCtx);
}
return;
}
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.partialResults = false;
this.freeUsings();
this.state = ComputedState.Updating;
this.iterator = this.call();
try {
this.iteratorNext(this.iterator!.next());
} catch (err) {
this.value = new CaughtException(err);
this.state = ComputedState.Updated;
this.invalidate();
}
b.setCurrentCtx(backupCurrentCtx);
}
update(): void {
if (alreadyInterrupted && this.partialResults) {
setPartialResults();
return;
}
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.partialResults = false;
this.freeUsings();
if (this.state === ComputedState.First) {
this.state = ComputedState.Updating;
this.value = this.call();
} else {
this.state = ComputedState.Updating;
let newResult = this.call();
if (!this.comparator(this.value, newResult)) {
this.value = newResult;
this.invalidate();
}
}
this.partialResults = alreadyInterrupted;
this.state = ComputedState.Updated;
promiseFulfilled(value: any) {
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.state = ComputedState.Updating;
try {
this.iteratorNext(this.iterator!.next(value));
} catch (err) {
this.value = new CaughtException(err);
this.state = ComputedState.Updated;
this.invalidate();
}
b.setCurrentCtx(backupCurrentCtx);
}
promiseFailed(err: any) {
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.state = ComputedState.Updating;
try {
this.iteratorNext(this.iterator!.throw!(err));
} catch (err) {
this.value = new CaughtException(err);
this.state = ComputedState.Updated;
this.invalidate();
}
b.setCurrentCtx(backupCurrentCtx);
}
promiseFailed(err: any) {
let backupCurrentCtx = b.getCurrentCtx();
b.setCurrentCtx(this as any);
this.state = ComputedState.Updating;
try {
this.iteratorNext(this.iterator!.throw!(err));
} catch (err) {
this.value = new CaughtException(err);
this.state = ComputedState.Updated;
this.invalidate();
}
b.setCurrentCtx(backupCurrentCtx);
}
this.freeUsings();
if (this.state === ComputedState.First) {
this.state = ComputedState.Updating;
this.value = this.call();
} else {
this.state = ComputedState.Updating;
let newResult = this.call();
if (!this.comparator(this.value, newResult)) {
this.value = newResult;
this.invalidate();
}
}
this.partialResults = alreadyInterrupted;
this.state = ComputedState.Updated;
b.setCurrentCtx(backupCurrentCtx);
if (this.partialResults) {
this.state = ComputedState.NeedRecheck;
setPartialResults();
}
}