|
|
|
@ -127,7 +127,17 @@ export function async_derived(fn, location) {
|
|
|
|
// If this code is changed at some point, make sure to still access the then property
|
|
|
|
// If this code is changed at some point, make sure to still access the then property
|
|
|
|
// of fn() to read any signals it might access, so that we track them as dependencies.
|
|
|
|
// of fn() to read any signals it might access, so that we track them as dependencies.
|
|
|
|
// We call `unset_context` to undo any `save` calls that happen inside `fn()`
|
|
|
|
// We call `unset_context` to undo any `save` calls that happen inside `fn()`
|
|
|
|
Promise.resolve(fn()).then(d.resolve, d.reject).then(unset_context);
|
|
|
|
Promise.resolve(fn())
|
|
|
|
|
|
|
|
.then(d.resolve, d.reject)
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
if (batch === current_batch && batch.committed) {
|
|
|
|
|
|
|
|
// if the batch was rejected as stale, we need to cleanup
|
|
|
|
|
|
|
|
// after any `$.save(...)` calls inside `fn()`
|
|
|
|
|
|
|
|
batch.deactivate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unset_context();
|
|
|
|
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
d.reject(error);
|
|
|
|
d.reject(error);
|
|
|
|
unset_context();
|
|
|
|
unset_context();
|
|
|
|
|