Last active
July 31, 2019 10:00
-
-
Save Fishbiscuit/55cefa25a34e0c30ee443afa247d6e09 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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