|
|
@ -185,15 +185,12 @@ export function user_effect(fn) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Non-nested `$effect(...)` in a component should be deferred
|
|
|
|
if (!active_reaction && active_effect && (active_effect.f & BRANCH_EFFECT) !== 0) {
|
|
|
|
// until the component is mounted
|
|
|
|
// Top-level `$effect(...)` in a component — defer until mount
|
|
|
|
var defer =
|
|
|
|
|
|
|
|
active_effect !== null && (active_effect.f & BRANCH_EFFECT) !== 0 && active_reaction === null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (defer) {
|
|
|
|
|
|
|
|
var context = /** @type {ComponentContext} */ (component_context);
|
|
|
|
var context = /** @type {ComponentContext} */ (component_context);
|
|
|
|
(context.e ??= []).push(fn);
|
|
|
|
(context.e ??= []).push(fn);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Everything else — create immediately
|
|
|
|
return create_user_effect(fn);
|
|
|
|
return create_user_effect(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|