Last active
April 3, 2020 20:22
-
-
Save sonntam/ba1b1ca8a3decea06a5c58cfd430ec62 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const mach1 = Machine({ | |
context: { | |
counter1: 0, | |
counter2: 0 | |
}, | |
type: 'parallel', | |
states: { | |
machine1: { | |
initial: 'idle1', | |
states: { | |
idle1: { | |
on: { | |
TRIGGER: 'count1' | |
} | |
}, | |
count1: { | |
after: { | |
5000: 'idle1', | |
500: { | |
actions: assign({ | |
counter1: (ctx) => ctx.counter1 + 1 | |
}), | |
target: 'count1', | |
internal: true | |
} | |
} | |
} | |
} | |
}, | |
machine2: { | |
initial: 'idle2', | |
states: { | |
idle2: { | |
on: { | |
TRIGGER: 'count2' | |
} | |
}, | |
count2: { | |
after: { | |
5000: 'idle2', | |
500: { | |
actions: assign({ | |
counter2: (ctx) => ctx.counter2 + 1 | |
}), | |
target: 'count2' | |
} | |
} | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment