Skip to content

Instantly share code, notes, and snippets.

@Baael
Created September 23, 2019 16:18
Show Gist options
  • Save Baael/01a129dbb4cfe354e9bae6c4aae9c564 to your computer and use it in GitHub Desktop.
Save Baael/01a129dbb4cfe354e9bae6c4aae9c564 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'fetch',
initial: 'idle',
states: {
idle: {
type: 'atomic',
on: {
FETCH: 'pending'
}
},
pending: {
type: 'parallel',
states: {
resource1: {
type: 'compound',
initial: 'pending',
states: {
pending: {
on: {
'FULFILL.resource1': 'success'
}
},
success: {
type: 'final'
}
}
},
resource2: {
type: 'compound',
initial: 'pending',
states: {
pending: {
on: {
'FULFILL.resource2': 'success'
}
},
success: {
type: 'final'
}
}
}
},
onDone: 'success'
},
success: {
type: 'compound',
initial: 'items',
states: {
items: {
on: {
'ITEM.CLICK': 'item'
}
},
item: {
on: {
BACK: 'items'
}
},
hist: {
type: 'history',
history: 'shallow'
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment