Skip to content

Instantly share code, notes, and snippets.

@fgandellini
Last active January 24, 2020 15:34
Show Gist options
  • Save fgandellini/520709639208ac6c19782ef4f01bd479 to your computer and use it in GitHub Desktop.
Save fgandellini/520709639208ac6c19782ef4f01bd479 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 portCallMachine = Machine({
id: 'port-call',
type: 'parallel',
states: {
mouse: {
initial: 'idle',
states: {
idle: {
on :{
MOUSE_MOVE: {
target: 'active',
cond: 'hitBycurrentRow',
},
},
},
active: {
on :{
MOUSE_MOVE: {
target: 'idle',
cond: 'notHitBycurrentRow',
},
MOUSE_ENTER: 'hovered',
},
},
hovered: {
on :{
MOUSE_LEAVE: [
{ target: 'idle', cond: 'notHitBycurrentRow' },
{ target: 'active', cond: 'hitBycurrentRow' },
],
MOUSE_CLICK: 'selected',
},
},
selected: {
on :{
MOUSE_CLICK_OUTSIDE: [
{ target: 'idle', cond: 'notHitBycurrentRow' },
{ target: 'active', cond: 'hitBycurrentRow' },
],
},
},
},
},
operations: {
initial: 'none',
states: {
none: {
on: {
LIVE_MOVES: {
target: 'pending',
cond: 'isFirstLiveMoves',
},
},
},
pending: {
on: {
LIVE_MOVES: {
target: 'completed',
cond: 'isLastLiveMoves',
},
},
},
completed: {},
},
},
},
}, {
guards: {
notHitBycurrentRow: () => true,
hitBycurrentRow: () => true,
isFirstLiveMoves: () => true,
isLastLiveMoves: () => true,
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment