Created
December 19, 2019 07:38
-
-
Save edokeh/126c64889d0b97d0bb50279fa7d93b07 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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) | |
let lionMachine = Machine( | |
{ | |
id: 'lion', | |
initial: 'idle', | |
context: { | |
displayIndex: 0 | |
}, | |
states: { | |
idle: { | |
on: { | |
CLICK: 'jiaohu', | |
UP_CLICK: 'preUpgrade' | |
}, | |
entry: 'play' | |
}, | |
jiaohu: { | |
type: 'parallel', | |
states: { | |
animation: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
LOOP_END_hudong: [ | |
{ | |
target: '#lion.idle', | |
in: '#lion.jiaohu.rpc.end' | |
}, | |
{ target: 'idle' } | |
] | |
}, | |
entry: 'play' | |
} | |
} | |
}, | |
rpc: { | |
initial: 'init', | |
states: { | |
init: { | |
invoke: { | |
src: 'poke', | |
onDone: 'end', | |
onError: 'end' | |
} | |
}, | |
end: { | |
type: 'final' | |
} | |
} | |
} | |
} | |
}, | |
preUpgrade: { | |
invoke: { | |
src: 'fetchUpgrade', | |
onDone: { | |
target: 'upgrade', | |
actions: assign((context, event) => ({ displayIndex: event.data.displayIndex })) | |
}, | |
onError: 'idle' | |
} | |
}, | |
upgrade: { | |
on: { | |
END: 'idle' | |
}, | |
entry: 'play' | |
} | |
} | |
}, | |
{} | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment