pull/12073/head
Rich Harris 6 months ago
parent a444746111
commit 51b78d7f9e

@ -93,7 +93,8 @@ function create_effect(type, fn, sync) {
parent: is_root ? null : current_effect,
prev: null,
teardown: null,
transitions: null
transitions: null,
version: 0
};
if (DEV) {

@ -3,6 +3,8 @@ import type { ComponentContext, Dom, Equals, TransitionManager } from '#client';
export interface Signal {
/** Flags bitmask */
f: number;
/** Write version */
version: number;
}
export interface Value<V = unknown> extends Signal {
@ -12,8 +14,6 @@ export interface Value<V = unknown> extends Signal {
equals: Equals;
/** The latest value for this signal */
v: V;
/** Write version */
version: number;
}
export interface Reaction extends Signal {

@ -180,13 +180,10 @@ export function check_dirtiness(reaction) {
if (!dependency.reactions?.includes(reaction)) {
(dependency.reactions ??= []).push(reaction);
}
}
if (dependency.version > /** @type {import('#client').Derived} */ (reaction).version) {
is_dirty = true;
}
} else if ((reaction.f & DIRTY) !== 0) {
// `signal` might now be dirty, as a result of calling `check_dirtiness` and/or `update_derived`
return true;
if (dependency.version > reaction.version) {
is_dirty = true;
}
}
}
@ -451,6 +448,8 @@ export function execute_effect(effect) {
execute_effect_teardown(effect);
var teardown = execute_reaction_fn(effect);
effect.teardown = typeof teardown === 'function' ? teardown : null;
effect.version = increment_version();
} catch (error) {
handle_error(/** @type {Error} */ (error), effect, current_component_context);
} finally {

Loading…
Cancel
Save