Skip to content

Instantly share code, notes, and snippets.

@michaelfig
Last active August 30, 2021 04:59
Show Gist options
  • Save michaelfig/f17a09d29905f966ce4e13318e1f076f to your computer and use it in GitHub Desktop.
Save michaelfig/f17a09d29905f966ce4e13318e1f076f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'Agoric Wallet Iframe Connection',
initial: 'idle',
context: {
location: null,
connecting: false,
},
states: {
idle: {
on: {
'': {
target: 'locating',
cond: context => {
return context.connecting;
},
},
},
},
locating: {
on: {
'': {
target: 'idle',
cond: context => !context.connecting,
},
},
},
bridging: {
on: {
'': {
target: 'idle',
cond: context => !context.connecting,
},
},
},
},
on: {
'UPDATE.LOCATION': {
target: 'bridging',
actions: assign({
location: (_, event) => event.value,
}),
cond: 'locationChanged',
},
},
guards: {
locationChanged: (context, event) => context.location !== event.value,
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment