Skip to content

Instantly share code, notes, and snippets.

@signaes
Last active September 21, 2020 22:42
Show Gist options
  • Save signaes/7c3351201ea9b2adfc2d92b3d9034551 to your computer and use it in GitHub Desktop.
Save signaes/7c3351201ea9b2adfc2d92b3d9034551 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 defineWorkoutMachine = Machine({
id: 'defineWorkoutMachine',
initial: 'idle',
context: {
},
states: {
idle: {
on: {
'EXERCISE.ADD': 'idle',
'EXERCISE.REMOVE': 'idle',
'EXERCISE.DRAG': 'idle',
'EXERCISE.DETAILS.UPDATE': 'idle',
'EXERCISE.DETAILS.SAVE': 'updating',
TOGGLE: 'toggling',
CREATE: 'creating',
UPDATE: 'updating',
DELETE: 'deleting',
CANCEL: 'complete',
}
},
creating: {
initial: 'idle',
states: {
idle: {
on: {
DONE: '#defineWorkoutMachine.idle',
ERROR: '.'
}
},
error: {
on: {
RETRY: 'idle'
}
}
}
},
updating: {
initial: 'idle',
states: {
idle: {
on: {
DONE: '#defineWorkoutMachine.idle',
ERROR: '.'
}
},
error: {
on: {
RETRY: 'idle'
}
}
}
},
toggling: {
initial: 'idle',
states: {
idle: {
on: {
DONE: '#defineWorkoutMachine.idle',
ERROR: '.'
}
},
error: {
on: {
RETRY: 'idle'
}
}
}
},
deleting: {
initial: 'idle',
states: {
idle: {
on: {
DONE: '#defineWorkoutMachine.complete',
ERROR: '.'
}
},
error: {
on: {
RETRY: 'idle'
}
}
}
},
complete: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment