slightly hacky fix. all tests passing

incremental-batches
Rich Harris 2 weeks ago
parent edd398900d
commit 2beb9eaf8f

@ -44,6 +44,7 @@ export const HEAD_EFFECT = 1 << 18;
export const EFFECT_PRESERVED = 1 << 19;
export const USER_EFFECT = 1 << 20;
export const EFFECT_OFFSCREEN = 1 << 25;
export const STATE_EAGER_EFFECT = 1 << 27;
// Flags exclusive to deriveds
/**

@ -17,7 +17,8 @@ import {
ERROR_VALUE,
MANAGED_EFFECT,
REACTION_RAN,
CONNECTED
CONNECTED,
STATE_EAGER_EFFECT
} from '#client/constants';
import { async_mode_flag } from '../../flags/index.js';
import { deferred, define_property, includes } from '../../shared/utils.js';
@ -1211,7 +1212,7 @@ export function eager(fn) {
version.label = '<eager>';
}
eager_effect(() => {
var effect = eager_effect(() => {
if (initial) {
// the first time this runs, we create an eager effect
// that will run eagerly whenever the expression changes
@ -1248,6 +1249,10 @@ export function eager(fn) {
}
});
// TODO ideally this wouldn't be necessary. I haven't figured out a way for these
// effects to correctly be marked dirty when `$state.eager(...)` arguments change
effect.f |= STATE_EAGER_EFFECT;
initial = false;
return value;

@ -28,7 +28,8 @@ import {
ROOT_EFFECT,
ASYNC,
WAS_MARKED,
CONNECTED
CONNECTED,
STATE_EAGER_EFFECT
} from '#client/constants';
import * as e from '../errors.js';
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
@ -269,7 +270,7 @@ export function flush_eager_effects() {
eager_effects_deferred = false;
for (const effect of eager_effects) {
if (is_dirty(effect)) {
if ((effect.f & STATE_EAGER_EFFECT) !== 0 || is_dirty(effect)) {
update_effect(effect);
}
}

Loading…
Cancel
Save