Permit undefined values to flow through
This commit is contained in:
parent
d8d94d1df0
commit
397fea5720
|
@ -66,23 +66,15 @@ export class Property<T> implements Computed<T> {
|
|||
else {
|
||||
try {
|
||||
// There's a callback; invoke it.
|
||||
let u: MaybeComputed<U> | undefined;
|
||||
try {
|
||||
mapValueCallbackRecursionCount++;
|
||||
u = callback(value);
|
||||
}
|
||||
finally {
|
||||
mapValueCallbackRecursionCount--;
|
||||
}
|
||||
if (u === undefined) {
|
||||
throw new Error("MapValue yielded no result");
|
||||
}
|
||||
|
||||
let u: MaybeComputed<U> = callback(value);
|
||||
// If this is another computed, we need to wire up to its resolution; else just store the value.
|
||||
if (u instanceof Promise) {
|
||||
if (u && u instanceof Promise) {
|
||||
u.then((v: U) => { result.setOutput(v, true, false); });
|
||||
}
|
||||
else if ((u as Computed<U>).mapValue) {
|
||||
else if (u && (u as Computed<U>).mapValue) {
|
||||
(u as Computed<U>).mapValue((v: U) => {
|
||||
result.setOutput(v, true, false);
|
||||
});
|
||||
|
@ -91,6 +83,10 @@ export class Property<T> implements Computed<T> {
|
|||
result.setOutput(<U>u, true, false);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
mapValueCallbackRecursionCount--;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
Log.error(`MapValue of a Computed yielded an unhandled error: ${err}`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue