Skip to content

Instantly share code, notes, and snippets.

@fleksin
Last active March 9, 2021 05:15
Show Gist options
  • Save fleksin/ddecd220c25f3ce26c0bd2e0bd6c884f to your computer and use it in GitHub Desktop.
Save fleksin/ddecd220c25f3ce26c0bd2e0bd6c884f 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: 'place-order',
initial: 'init',
context: {
retries: 0
},
states: {
init: {
on: {
hasOrderNo: 'orderCreated',
hasBookKey: 'fetch_show_by_book_key'
}
},
fetch_show_by_book_key: {
on: {
SUCCESS: 'idle',
FAIL: 'failure'
}
},
idle: {
id: 'confirm-order',
type: 'parallel',
// initial: 'init',
states: {
address: {
// on: {
// aaa: 'next'
// }
},
goods: {
},
ump: {
}
},
on: {
SUBMIT: "orderCreated",
FETCH_SHOW: {
actions: []
}
}
},
failure: {
on: {
RETRY: {
target: 'fetch_show_by_book_key',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
},
orderCreated: {
type: 'final'
},
loading: {
on: {
finish: 'idle'
}
}
},
on: {
LOADING: {
target: '.loading'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment