Skip to content

Instantly share code, notes, and snippets.

@hydra1983
Last active November 27, 2021 17:18
Show Gist options
  • Save hydra1983/0f0217410b32956cad44223556750fed to your computer and use it in GitHub Desktop.
Save hydra1983/0f0217410b32956cad44223556750fed to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const editPageMachine = Machine({
id: 'editPage',
initial: 'preparing',
states: {
preparing: {
on: {
CREAT_ENTITY: 'creating',
UPDATE_ENTITY: 'updating'
}
},
creating: {
initial: 'idle',
states: {
idle: {
on: {
LOAD_DATA: 'loading',
SAVE_ENTITY: 'saving',
CANCEL_CREATING: 'canceling',
}
},
loading: {
on: {
LOAD_SUCCEEDED: 'idle',
LOAD_FAILED: 'idle'
}
},
saving: {
on: {
SAVE_SUCCEEDED: 'idle',
SAVE_FAILED: 'idle'
}
},
canceling: {
on: {
'': '#editPage.left'
}
},
}
},
updating: {
initial: 'idle',
states: {
idle: {
on: {
LOAD_DATA: 'loading',
SAVE_ENTITY: 'saving',
DELETE_ENTITY: 'deleting',
}
},
loading: {
on: {
LOAD_SUCCEEDED: 'idle',
LOAD_FAILED: 'idle'
}
},
saving: {
on: {
SAVE_SUCCEEDED: 'idle',
SAVE_FAILED: 'idle'
}
},
deleting: {
on: {
DELETE_SUCCEEDED: '#editPage.left',
DELETE_FAILED: 'idle'
}
},
}
},
left: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment