Skip to content

Instantly share code, notes, and snippets.

@john-bell-gw
Created October 19, 2022 09:57
Show Gist options
  • Save john-bell-gw/9237ba632a66b64f0131079cc0fa0551 to your computer and use it in GitHub Desktop.
Save john-bell-gw/9237ba632a66b64f0131079cc0fa0551 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 createPublication = () => console.log('createPublication')
const login = () => console.log('login')
const removeRequest = () => console.log('removeRequest')
const requestGeneralError = () => console.log('requestGeneralError')
const requestSuccess = () => console.log('requestSuccess')
const setUserRole = () => console.log('setUserRole')
const updateUserAuthInfo = () => console.log('updateUserAuthInfo')
const userSearch = () => console.log('userSearch')
const userSearchDone = () => console.log('userSearchDone')
const checkUserIsAuthenticated = () => console.log('checkUserIsAuthenticated')
const getRole = () => console.log('getRole')
const fetchMachine = Machine({
id: "cloud-native-tooling-app",
initial: "authentication",
states: {
authentication: {
always: checkUserIsAuthenticated,
},
getRole: {
invoke: {
id: "getRole",
src: getRole,
},
on: {
SETUSERROLE: {
target: "idle",
actions: setUserRole,
},
},
},
idle: {},
},
on: {
LOGIN: {
actions: login,
},
CREATEPUBLICATION: {
actions: [createPublication],
},
"CREATEPUBLICATION.DONE": { actions: [requestSuccess] },
USERSEARCH: {
actions: userSearch,
},
"USERSEARCH.DONE": {
actions: [userSearchDone],
},
UPDATEUSERAUTHINFO: { actions: [updateUserAuthInfo] },
"REQUEST.GENERALERROR": { actions: [requestGeneralError] },
"REQUEST.REMOVE": { actions: removeRequest },
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment