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

Function receive

packages/xstate-store/src/store.ts:279–302  ·  view source on GitHub ↗
(event: StoreEvent)

Source from the content-addressed store, hash-verified

277 };
278
279 function receive(event: StoreEvent) {
280 const [nextSnapshot, effects] = transition(currentSnapshot, event);
281 currentSnapshot = nextSnapshot;
282
283 atom.set(nextSnapshot);
284 notifyInspection(event, nextSnapshot);
285
286 let committed = false;
287 const effectEnqueue = {
288 trigger,
289 send,
290 getSnapshot: () => (committed ? currentSnapshot : nextSnapshot)
291 } as StoreEffectEnqueue<any, any>;
292
293 for (const effect of effects) {
294 if (typeof effect === 'function') {
295 effect(effectEnqueue);
296 } else {
297 emit(effect);
298 }
299 }
300
301 committed = true;
302 }
303
304 const trigger =
305 eventTypes && eventTypes.length > 0

Callers 7

sendFunction · 0.85
actor.test.tsFile · 0.85
actions.test.tsFile · 0.85
actorLogic.test.tsFile · 0.85
system.test.tsFile · 0.85
invoke.test.tsFile · 0.85

Calls 5

notifyInspectionFunction · 0.85
transitionFunction · 0.70
effectFunction · 0.70
emitFunction · 0.70
setMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…