incremental-batches
Rich Harris 3 weeks ago
parent f31e715569
commit f48e4e2ec5

@ -39,7 +39,7 @@ import { UNINITIALIZED } from '../../../constants.js';
import { set_signal_status } from './status.js';
import { legacy_is_updating_store } from './store.js';
import { invariant } from '../../shared/dev.js';
import { log_effect_tree } from '../dev/debug.js';
import { log_effect_tree, root } from '../dev/debug.js';
/** @type {Set<Batch>} */
const batches = new Set();

@ -103,7 +103,7 @@ function create_effect(type, fn) {
ctx: component_context,
deps: null,
nodes: null,
f: type | DIRTY | CONNECTED,
f: type | CLEAN | CONNECTED,
first: null,
fn,
last: null,
@ -113,6 +113,7 @@ function create_effect(type, fn) {
prev: null,
teardown: null,
wv: 0,
rv: -1,
ac: null
};

@ -371,7 +371,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
}
} else if (not_dirty) {
} else {
var effect = /** @type {Effect} */ (reaction);
if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {

@ -8,7 +8,7 @@ const STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
* @param {number} status
*/
export function set_signal_status(signal, status) {
signal.f = (signal.f & STATUS_MASK) | status;
// signal.f = (signal.f & STATUS_MASK) | status;
}
/**

@ -11,6 +11,8 @@ import type { Boundary } from '../dom/blocks/boundary';
export interface Signal {
/** Flags bitmask */
f: number;
/** Read version */
rv: number;
/** Write version */
wv: number;
}
@ -20,11 +22,8 @@ export interface Value<V = unknown> extends Signal {
equals: Equals;
/** Signals that read from this signal */
reactions: null | Reaction[];
/** Read version */
rv: number;
/** The latest value for this signal */
v: V;
// dev-only
/** A label (e.g. the `foo` in `let foo = $state(...)`) used for `$inspect.trace()` */
label?: string;

@ -156,26 +156,25 @@ export function increment_write_version() {
export function is_dirty(reaction) {
var flags = reaction.f;
if ((flags & DIRTY) !== 0) {
return true;
}
if (flags & DERIVED) {
reaction.f &= ~WAS_MARKED;
}
if ((flags & MAYBE_DIRTY) !== 0) {
var dependencies = /** @type {Value[]} */ (reaction.deps);
var dependencies = /** @type {Value[]} */ (reaction.deps);
if (dependencies !== null) {
var length = dependencies.length;
for (var i = 0; i < length; i++) {
var dependency = dependencies[i];
if (is_dirty(/** @type {Derived} */ (dependency))) {
update_derived(/** @type {Derived} */ (dependency));
if ((dependency.f & DERIVED) !== 0) {
if (is_dirty(/** @type {Derived} */ (dependency))) {
update_derived(/** @type {Derived} */ (dependency));
}
}
if (dependency.wv > reaction.wv) {
if (dependency.wv > reaction.rv) {
return true;
}
}
@ -190,6 +189,8 @@ export function is_dirty(reaction) {
}
}
reaction.rv = write_version;
return false;
}
@ -254,6 +255,8 @@ export function update_reaction(reaction) {
}
try {
reaction.wv = reaction.rv = write_version;
reaction.f |= REACTION_IS_UPDATING;
var fn = /** @type {Function} */ (reaction.fn);
var result = fn();

Loading…
Cancel
Save