add test, add to server (noop)

pull/15673/head
ComputerGuy 5 months ago
parent a1a13d7a24
commit 765b3566ce

@ -25,6 +25,10 @@ export function CallExpression(node, context) {
return b.arrow([], b.block([])); return b.arrow([], b.block([]));
} }
if (rune === '$state.invalidate') {
return b.void0;
}
if (rune === '$state.snapshot') { if (rune === '$state.snapshot') {
return b.call( return b.call(
'$.snapshot', '$.snapshot',

@ -8,7 +8,13 @@ import {
render_effect, render_effect,
user_effect user_effect
} from '../../src/internal/client/reactivity/effects'; } from '../../src/internal/client/reactivity/effects';
import { state, set, update, update_pre } from '../../src/internal/client/reactivity/sources'; import {
state,
set,
update,
update_pre,
invalidate
} from '../../src/internal/client/reactivity/sources';
import type { Derived, Effect, Value } from '../../src/internal/client/types'; import type { Derived, Effect, Value } from '../../src/internal/client/types';
import { proxy } from '../../src/internal/client/proxy'; import { proxy } from '../../src/internal/client/proxy';
import { derived } from '../../src/internal/client/reactivity/deriveds'; import { derived } from '../../src/internal/client/reactivity/deriveds';
@ -1212,4 +1218,24 @@ describe('signals', () => {
destroy(); destroy();
}; };
}); });
test('invalidate reruns dependent effects', () => {
let updates = 0;
return () => {
const a = state(0);
const destroy = effect_root(() => {
render_effect(() => {
$.get(a);
updates++;
});
});
set(a, 1);
flushSync();
assert.equal(updates, 2);
invalidate(a);
flushSync();
assert.equal(updates, 3);
destroy();
};
});
}); });

Loading…
Cancel
Save