Skip to content

Instantly share code, notes, and snippets.

@kevinfoerster
Created January 7, 2020 17:37
Show Gist options
  • Save kevinfoerster/0e127c29e87ee0d05c5eeeb9eab649c6 to your computer and use it in GitHub Desktop.
Save kevinfoerster/0e127c29e87ee0d05c5eeeb9eab649c6 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: 'fetch',
initial: 'closed',
context: {
activeItem: null
},
states: {
closed: {
on: {
OPEN: {
target: 'opening',
actions: ['openOverlay', 'setItem']
}
}
},
opening: {
on: {
"": {
target: "open",
}
}
},
open: {
on: {
CLOSE: {
target: 'closing',
actions: ['closeOverlay', 'resetItem']
},
OPEN: {
target: '.',
actions: ['setItem']
}
}
},
closing: {
on: {
'': {
target: 'closed'
}
}
}
}
}, {
actions:{
openOverlay: assign({
}),
closeOverlay: assign({
}),
resetItem: assign({
activeItem: null
}),
setItem: assign({
activeItem: (ctx, e) => e.item
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment