Skip to content

Instantly share code, notes, and snippets.

@pavankataria
Last active January 3, 2021 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavankataria/ec0aebf7aab95d8595c2a41beab30a18 to your computer and use it in GitHub Desktop.
Save pavankataria/ec0aebf7aab95d8595c2a41beab30a18 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const factoryViewing = Machine({
id: 'factoryViewing',
initial: 'idle',
states: {
idle: {
on: {
LOAD: 'loading'
}
},
loading: {
on: {
SUCCESS: 'interacting',
ON_EMPTY: 'empty',
DID_ERROR: 'error',
}
},
// State
interacting: {
initial: 'idle',
states: {
// State
idle: {
on: {
HAS_ORDERS: 'factorySelection',
NO_ORDERS: 'empty',
}
},
// State
factorySelection: {
on: {
SELECT_FACTORY: 'specificFactoryView'
}
},
// State
specificFactoryView: {
initial: 'idle',
on: {
UNSELECT_FACTORY: 'factorySelection',
SELECT_FACTORY: 'specificFactoryView',
},
states: {
// State
idle: {
on: {
HAS_DATA: 'orders',
NO_DATA: 'dispatchedAll',
}
},
// State
dispatchedAll: {},
orders: {
initial: 'noOrdersSelected',
states: {
noOrdersSelected: {
on: {
SELECT_ORDER: 'specificOrder',
}
},
specificOrder: {
on: {
SELECT_ORDER: 'specificOrder',
}},
}
},
}
},
empty: {},
}
},
empty: {},
error: {}
},
on: {
RELOAD: 'loading'
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment