Last active
June 22, 2020 22:07
-
-
Save wighawag/1b310d1bc26f731465e483eff1c5712a 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
Machine({ | |
id: 'wallet', | |
type: "parallel", | |
context: { | |
address: undefined, | |
vendor: undefined, | |
}, | |
states: { | |
builtin: { | |
initial: 'unknown', | |
on: { | |
PROBE: { | |
target: '.probing', | |
in: 'builtin.unknown', | |
}, | |
}, | |
states: { | |
unknown: {}, | |
probing: { | |
entry: 'probe', | |
on: { | |
FOUND: 'available', | |
NOT_FOUND: 'notAvailable', | |
ERROR: { | |
target: 'unknown', | |
actions: 'error_probing', | |
} | |
}, | |
}, | |
available: { | |
type: 'final', | |
}, | |
notAvailable: { | |
type: 'final', | |
}, | |
} | |
}, | |
account: { | |
initial: 'unknown', | |
on: { | |
SELECT: { | |
target: '.loading', | |
in: 'account.unknown', | |
}, | |
}, | |
states: { | |
unknown: {}, | |
loading: { | |
entry: 'select', | |
on: { | |
"": [ | |
{ | |
target: "connecting", | |
in: "builtin.available", | |
}, | |
{ | |
target: "unknown", | |
in: "builtin.notAvailable", | |
actions: 'error_loading', | |
}, | |
], | |
ERROR: { | |
target: 'unknown', | |
actions: 'error_loading', | |
}, | |
}, | |
}, | |
connecting: { | |
on: { | |
CONNECTED: 'connected', | |
}, | |
ERROR: { | |
target: 'unknown', | |
actions: 'error_connecting', | |
} | |
}, | |
connected: { | |
initial: 'locked', | |
states: { | |
locked: {}, | |
ready: { | |
activities: ['watch'], | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
{ | |
guards: { | |
}, | |
actions: { | |
error_loading: assign({ | |
error: 'could not load' | |
}), | |
error_connecting: assign({ | |
error: 'could not connect' | |
}), | |
error_probing:assign({ | |
error: 'could not probe' | |
}), | |
select: send('PROBE'), | |
probe: () => { | |
console.log('probe'); | |
}, | |
}, | |
activities: { | |
watch: () => { | |
const interval = setInterval(() => console.log('BEEP!'), 1000); | |
return () => clearInterval(interval); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment