Skip to content

Instantly share code, notes, and snippets.

@tcodes0
Last active September 16, 2020 22:08
Show Gist options
  • Save tcodes0/2d25b9857e04c2409d4a85265ee0efca to your computer and use it in GitHub Desktop.
Save tcodes0/2d25b9857e04c2409d4a85265ee0efca to your computer and use it in GitHub Desktop.
new note
const newNoteMachine = Machine({
id: 'newNoteMachine',
type: 'parallel',
context: { id: null },
states: {
userPrompt: {
initial: 'prompting',
states: {
prompting: { on: { INPUT: { target: 'working' } }, invoke: { src: 'userPrompt_prompting' } },
working: {
on: { NOTE_VALIDATION_FAILED: { target: 'invalidInput' }, NOTE_SAVED: { target: 'prompting' } },
invoke: { src: 'userPrompt_working' },
},
invalidInput: { on: { OUTPUT_RESULT: { target: 'prompting' } } },
},
},
newNoteFlow: {
initial: 'name',
states: {
name: { on: { NOTE_SAVED: { target: 'text', actions: 'saveId' } } },
text: { on: { NOTE_SAVED: { target: 'tags' } } },
tags: { on: { NOTE_SAVED: { target: 'links' } } },
links: { on: { NOTE_SAVED: { target: 'done' } } },
done: { type: 'final' },
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment