Skip to content

Instantly share code, notes, and snippets.

@fleksin
Last active September 29, 2019 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fleksin/c235a95e82a79d0182ac16e1a560aa22 to your computer and use it in GitHub Desktop.
Save fleksin/c235a95e82a79d0182ac16e1a560aa22 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine( {
id: 'stateMachine',
initial: 'isInApp',
states: {
isInApp: {
invoke: {
id: 'isInAlipay',
src: () => Promise.resolve(),
onDone: {
target: 'inApp',
},
onError: {
target: 'notInApp',
},
},
},
notInApp: {
invoke: {
id: 'notInAppThenWait',
src: () => Promise.resolve,
onDone: 'isInApp',
onError: 'notInApp',
},
},
inApp: {
initial: 'isInMiniApp',
states: {
isInMiniApp: {
invoke: {
id: 'isInMiniApp',
src: () => Promise.resolve(),
onDone: {
target: 'inMiniApp',
},
onError: {
target: 'notInMiniApp',
},
},
},
inMiniApp: {
// entry: () => {
// console.log('in mini app');
// },
type: 'final',
},
notInMiniApp: {
entry: () => {
console.log('not in mini app');
},
invoke: {
id: 'notInMpThenWait',
src: () => Promise.resolve(),
onDone: {
target: 'isInMiniApp',
},
onError: {
target: 'notInMiniApp',
},
},
},
},
onDone: 'testFinished',
on: {
KILL_APP: 'notInApp',
HOME: 'notInApp',
GO_TO_APP: 'notInApp',
},
},
testFinished: {
type: 'final',
},
},
},
{
actions: {},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment