Skip to content

Instantly share code, notes, and snippets.

@dreyescat
Last active January 13, 2021 14:28
Show Gist options
  • Save dreyescat/38c16eac84dcc27f20263ac5998d4e8c to your computer and use it in GitHub Desktop.
Save dreyescat/38c16eac84dcc27f20263ac5998d4e8c 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: 'company',
initial: 'undefined',
context: {
name: '',
assignedTo: undefined
},
states: {
undefined: {
on: {
CREATE: 'created'
}
},
created: {
initial: 'new',
on: {
DELETE: 'undefined'
},
states: {
new: {
'always': [{
cond: 'isAssigned',
target: 'delivered',
}, {
target: 'backlog'
}]
},
backlog: {
on: {
UPDATE: [{
cond: 'isAssigned',
target: 'delivered'
}]
}
},
delivered: {
on: {
UPDATE: [{
cond: 'isUnassigned',
target: 'backlog'
}]
}
}
}
}
}
}, {
guards: {
isAssigned: (context, event) => context.assignedTo !== undefined,
isUnassigned: (context, event) => context.assignedTo === undefined
}
});
@dreyescat
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment