Skip to content

Instantly share code, notes, and snippets.

@fleksin
Last active February 28, 2021 08:57
Show Gist options
  • Save fleksin/f6a89fe64ca3bdd85c99a1fa8913bdd7 to your computer and use it in GitHub Desktop.
Save fleksin/f6a89fe64ca3bdd85c99a1fa8913bdd7 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: '进入下单页',
context: {
retries: 0
},
states: {
// loading: {
// on: {
// FETCH_SHOW_SUCCESS:'idle',
// FETCH_SHOW_FAIL:'idle',
// }
// },
'进入下单页': {
on: {
FETCH_SHOW_BY_BOOK_KEY: '修改订单'
}
},
idle: {
on: {
FETCH_SHOW: '进入下单页'
}
},
'修改订单': {
on: {
SUCCESS: '订单提交成功',
FAIL: '订单提交失败'
}
},
'订单提交成功': {
type: 'final'
},
'订单提交失败': {
on: {
RETRY: {
target: '修改订单',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment