Skip to content

Instantly share code, notes, and snippets.

@Fishbiscuit
Last active July 31, 2019 10:00
Show Gist options
  • Save Fishbiscuit/55cefa25a34e0c30ee443afa247d6e09 to your computer and use it in GitHub Desktop.
Save Fishbiscuit/55cefa25a34e0c30ee443afa247d6e09 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const promiseMachine = Machine({
id: 'promise',
initial: 'Request_Received',
states: {
Request_Received: {
on: {
// state transition (shorthand)
// this is equivalent to { target: 'resolved' }
RESOLVE: 'Booking_Tool',
// state transition (object)
REJECT: {
target: 'rejected'
}
}
},
Booking_Tool:{
initial: 'Password_Access',
states: {
Password_Access: {
on: {
ENTER: 'Calendar'
}
},
Calendar: {
on: {
NEXT: 'third'
}
},
third: {
type: 'final'
}
}
},
rejected: {
type: 'final'
}
}
});
const { initialState } = promiseMachine;
console.log(initialState.value);
// => 'pending'
const nextState = promiseMachine.transition(initialState, 'RESOLVE');
console.log(nextState.value);
// => 'resolved'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment