Skip to content

Instantly share code, notes, and snippets.

@baig
Last active December 12, 2019 22:28
Show Gist options
  • Save baig/bbc8c30923813bb727f66119b55a7382 to your computer and use it in GitHub Desktop.
Save baig/bbc8c30923813bb727f66119b55a7382 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const makeBoolState = (trueName, falseName, initial='false') => ({
initial,
states: {
true: { on: { [falseName]: 'false' } },
false: { on: { [trueName]: 'true' } },
}
});
const siogenMachine = Machine({
id: 'siogen-form',
initial: 'editing',
// context: { amount: 0 },
states: {
editing: {
type: 'parallel',
states: {
simType: {
initial: 'generated',
states: {
generated: {
on: {
FROM_FILE: 'fromFile',
FROM_SATELLITE: 'satellite',
}
},
fromFile: {
on: {
FROM_SATELLITE: 'satellite',
GENERATED: 'generated',
}
},
satellite: {
on: {
FROM_FILE: 'fromFile',
GENERATED: 'generated',
}
},
}
},
verifyMode: {
initial: 'disabled',
states: {
disabled: {
on: {
ENALBE_VERIFY: 'disable',
}
},
disable: {
on: {
CHECK_BIT_ERRORS: 'withBitErrorCheck',
DONT_CHECK_BIT_ERRORS: 'noBitErrorCheck',
}
},
withBitErrorCheck: {
on: {
DISABLE_VERIFY: 'disable',
DONT_CHECK_BIT_ERRORS: 'noBitErrorCheck',
}
},
noBitErrorCheck: {
on: {
CHECK_BIT_ERRORS: 'withBitErrorCheck',
DISABLE_VERIFY: 'disable',
}
},
}
},
rxEnable: makeBoolState('ENABLE_RECEPTION', 'DISABLE_RECEPTION'),
txEnable: makeBoolState('ENABLE_TRANSMISSION', 'DISABLE_TRANSMISSION'),
powerUpState: makeBoolState('ENABLE_POWERUP', 'DISABLE_POWERUP'),
}
},
// invalid: {},
submit: {type: 'final'},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment