Skip to content

Instantly share code, notes, and snippets.

@FilDevTronic
Created November 24, 2019 16:27
Show Gist options
  • Save FilDevTronic/2654a249e2646fd08238d3f819e0036e to your computer and use it in GitHub Desktop.
Save FilDevTronic/2654a249e2646fd08238d3f819e0036e 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 unitTaskManagerMachine = Machine({
id: 'unitTaskManager',
initial: 'idle',
states: {
idle: {
on: {
'': [
{ target: 'noFurtherAction', cond: "hasNoFurtherAction" },
{ target: 'error.noPhase', cond: 'hasNoPhase'},
{ target: 'ready' }
]
}
},
noFurtherAction: {
type: 'final'
},
error: {
states: {
noPhase: {}
},
on: {
RETRY: 'idle'
}
},
ready: {
on: {
START: 'applyOutcomes'
},
meta: {
message: 'Start '
}
},
applyOutcomes: {
initial: 'working',
states: {
working: {
on: {
REVIEW: 'review'
}
},
review: {
on: {
SAVE: {
target: '#unitTaskManager.idle',
actions: "saveOutcomes"
}
}
},
}
}
}
},
{
guards: {
hasNoFurtherAction: (ctx, e) => { return false },
hasNoPhase: (ctx, e) => { return false }
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment