make purpose explicit

aa-coordination
Rich Harris 7 months ago
parent d155191556
commit c9d61951c6

@ -19,7 +19,7 @@ export const EFFECT_TRANSPARENT = 1 << 17;
export const LEGACY_DERIVED_PROP = 1 << 18;
export const INSPECT_EFFECT = 1 << 19;
export const HEAD_EFFECT = 1 << 20;
export const EFFECT_HAS_DERIVED = 1 << 21;
export const EFFECT_PRESERVED = 1 << 21; // effects with this flag should not be pruned
// Flags used for async
export const REACTION_IS_UPDATING = 1 << 22;

@ -3,6 +3,7 @@
import {
BOUNDARY_EFFECT,
BOUNDARY_SUSPENDED,
EFFECT_PRESERVED,
EFFECT_TRANSPARENT,
RENDER_EFFECT
} from '../../constants.js';
@ -63,6 +64,8 @@ function with_boundary(boundary, fn) {
}
}
var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
/**
* @param {TemplateNode} node
* @param {{
@ -317,7 +320,7 @@ export function boundary(node, props, children) {
}
reset_is_throwing_error();
}, EFFECT_TRANSPARENT | BOUNDARY_EFFECT);
}, flags);
if (hydrating) {
anchor = hydrate_node;

@ -5,7 +5,7 @@ import {
DERIVED,
DESTROYED,
DIRTY,
EFFECT_HAS_DERIVED,
EFFECT_PRESERVED,
MAYBE_DIRTY,
UNOWNED
} from '../constants.js';
@ -58,7 +58,7 @@ export function derived(fn) {
} else {
// Since deriveds are evaluated lazily, any effects created inside them are
// created too late to ensure that the parent effect is added to the tree
active_effect.f |= EFFECT_HAS_DERIVED;
active_effect.f |= EFFECT_PRESERVED;
}
/** @type {Derived<V>} */
@ -140,7 +140,7 @@ export function async_derived(fn) {
// TODO we should probably null out active effect here,
// rather than inside `restore()`
}
}, EFFECT_HAS_DERIVED);
}, EFFECT_PRESERVED);
return Promise.resolve(promise).then(() => value);
}

@ -34,7 +34,7 @@ import {
INSPECT_EFFECT,
HEAD_EFFECT,
MAYBE_DIRTY,
EFFECT_HAS_DERIVED,
EFFECT_PRESERVED,
BOUNDARY_EFFECT
} from '../constants.js';
import { set } from './sources.js';
@ -147,7 +147,7 @@ function create_effect(type, fn, sync, push = true) {
effect.first === null &&
effect.nodes_start === null &&
effect.teardown === null &&
(effect.f & (EFFECT_HAS_DERIVED | BOUNDARY_EFFECT)) === 0;
(effect.f & EFFECT_PRESERVED) === 0;
if (!inert && !is_root && push) {
if (parent_effect !== null) {

Loading…
Cancel
Save