|
|
@ -97,17 +97,6 @@ function get_parent_context(component_context) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Capture the current component context so that we can restore it after an async operation completes.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function capture() {
|
|
|
|
|
|
|
|
var previous_component = current_component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return function restore() {
|
|
|
|
|
|
|
|
current_component = previous_component;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Wraps an `await` expression in such a way that the component context that was
|
|
|
|
* Wraps an `await` expression in such a way that the component context that was
|
|
|
|
* active before the expression evaluated can be reapplied afterwards —
|
|
|
|
* active before the expression evaluated can be reapplied afterwards —
|
|
|
@ -118,11 +107,11 @@ function capture() {
|
|
|
|
* @returns {Promise<() => T>}
|
|
|
|
* @returns {Promise<() => T>}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export async function save(promise) {
|
|
|
|
export async function save(promise) {
|
|
|
|
var restore = capture();
|
|
|
|
var previous_component = current_component;
|
|
|
|
var value = await promise;
|
|
|
|
var value = await promise;
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
restore();
|
|
|
|
current_component = previous_component;
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|