Last active
May 29, 2020 17:54
-
-
Save Lucasdsk/8a0a6e98fc2e936e3c2cb53c8a46eae6 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const openingMachine = Machine({ | |
id: 'opening', | |
initial: 'idle', | |
context: { | |
message: '' | |
}, | |
states: { | |
idle: { | |
on: { | |
PUBLISH: 'publishing', | |
SAVE: 'saving' | |
} | |
}, | |
publishing: { | |
initial: 'loading', | |
states: { | |
loading: { | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure' | |
} | |
}, | |
success: { | |
type: 'final', | |
}, | |
failure: { | |
actions: assign({ | |
message: 'Erro ao publicar' | |
}) | |
} | |
}, | |
onDone: { | |
target: 'idle', | |
actions: assign({ | |
message: 'Vaga publicada' | |
}) | |
} | |
}, | |
saving: { | |
initial: 'loading', | |
states: { | |
loading: { | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure' | |
} | |
}, | |
success: { | |
type: 'final', | |
}, | |
failure: { | |
invoke: { | |
src: () => Promise.reject(), | |
onError: { | |
target: '#opening.idle', | |
actions: assign({ | |
message: 'Erro ao salvar' | |
}) | |
} | |
} | |
} | |
}, | |
onDone: { | |
target: 'idle', | |
actions: assign({ | |
message: 'Vaga Salva' | |
}) | |
} | |
} | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment