MCPcopy
hub / github.com/statelyai/xstate / effect

Function effect

packages/xstate-store/src/alien.ts:440–460  ·  view source on GitHub ↗
(fn: () => void)

Source from the content-addressed store, hash-verified

438}
439
440export function effect(fn: () => void): () => void {
441 const e: EffectNode = {
442 fn,
443 subs: undefined,
444 subsTail: undefined,
445 deps: undefined,
446 depsTail: undefined,
447 flags: ReactiveFlags.Watching | ReactiveFlags.RecursedCheck
448 };
449 const prevSub = setActiveSub(e);
450 if (prevSub !== undefined) {
451 link(e, prevSub, 0);
452 }
453 try {
454 e.fn();
455 } finally {
456 activeSub = prevSub;
457 e.flags &= ~ReactiveFlags.RecursedCheck;
458 }
459 return effectOper.bind(e);
460}
461
462export function effectScope(fn: () => void): () => void {
463 const e: ReactiveNode = {

Callers

nothing calls this directly

Calls 3

setActiveSubFunction · 0.85
linkFunction · 0.85
fnMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…