Created
January 5, 2022 07:38
-
-
Save Dengyy/c065f4b23c7703cbd8b32033973a6a3a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const machine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
states: { | |
idle: { | |
type: 'atomic', | |
on: { | |
FETCH: { target: 'pending' } | |
} | |
}, | |
pending: { | |
type: 'parallel', | |
states: { | |
resource1: { | |
type: 'compound', | |
initial: 'pending', | |
states: { | |
pending: { | |
on: { | |
'FULFILL.resource1': { target: 'success' } | |
} | |
}, | |
success: { | |
type: 'final' | |
} | |
} | |
}, | |
resource2: { | |
type: 'compound', | |
initial: 'pending', | |
states: { | |
pending: { | |
on: { | |
'FULFILL.resource2': { target: 'success' } | |
} | |
}, | |
success: { | |
type: 'final' | |
} | |
} | |
} | |
}, | |
onDone: 'success' | |
}, | |
success: { | |
type: 'compound', | |
initial: 'items', | |
states: { | |
items: { | |
on: { | |
'ITEM.CLICK': { target: 'item' } | |
} | |
}, | |
item: { | |
on: { | |
BACK: { target: 'items' } | |
} | |
}, | |
hist: { | |
type: 'history', | |
history: 'shallow' | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment