Last active
June 22, 2020 15:49
-
-
Save wighawag/3274dd9dd84df8692db0c2169cfc3014 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, | |
}, | |
states: { | |
builtin: { | |
initial: 'unknown', | |
context: { | |
error: undefined, | |
}, | |
states: { | |
unknown: { | |
on: { | |
PROBE: 'probing', | |
}, | |
}, | |
probing: { | |
on: { | |
ERROR: { | |
target: 'unknown', | |
actions: assign({ | |
error: () => "failed to probe", | |
}), | |
}, | |
FOUND: 'available', | |
NOT_FOUND: 'notAvailable', | |
} | |
}, | |
available: { | |
type: 'final', | |
}, | |
notAvailable: { | |
type: 'final', | |
}, | |
} | |
}, | |
account: { | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
SELECT: 'loading', | |
} | |
}, | |
loading: { | |
entry: 'select', | |
on: { | |
FOUND: 'connecting', | |
ERROR: { | |
target: 'unknown', | |
actions: assign({ | |
error: () => "failed to load wallet", | |
}), | |
}, | |
}, | |
}, | |
connecting: { | |
on: { | |
CONNECTED: 'connected', | |
ERROR: { | |
target: 'unknown', | |
actions: assign({ | |
error: () => "failed to connect to wallet", | |
}), | |
}, | |
}, | |
}, | |
connected: { | |
initial: 'locked', | |
states: { | |
locked: {}, | |
ready: { | |
activities: ['watch'], | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
{ | |
actions: { | |
select: send('PROBE'), | |
// pure((context, event) => { | |
// if (!context.vendor) { | |
// return send('PROBE'); | |
// } | |
// }), | |
probe: () => { | |
console.log('probe'); | |
}, | |
builtin_found: assign({ | |
vendor: true | |
}), | |
builtin_not_found: assign({ | |
vendor: true | |
}) | |
}, | |
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