Skip to content

Instantly share code, notes, and snippets.

@mvladic
Last active December 6, 2020 18:55
Show Gist options
  • Save mvladic/e47bec772d064d3ead696de0144079b3 to your computer and use it in GitHub Desktop.
Save mvladic/e47bec772d064d3ead696de0144079b3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fileMachine = Machine({
id: 'bb3',
initial: 'not_ready',
states: {
not_ready: {
on: {
SPI_READY: 'ready'
}
},
ready: {
on: {
UPDATE: {
target: 'update_and_get_state',
actions: "transfer"
},
DISK_OPERATION: {
target: 'disk_operation'
}
},
after: {
250: {
target: 'update_and_get_state',
actions: "transfer"
}
}
},
update_and_get_state: {
on: {
TRANSFER_OK: {
target: "not_ready",
actions: "updateState"
},
TRANSFER_ERROR: {
target: "not_ready",
actions: "onError"
}
}
},
disk_operation: {
entry: "transferDiskOperation",
on: {
TRANSFER_OK: {
target: "disk_operation_result"
},
TRANSFER_ERROR: {
target: "disk_operation"
}
}
},
disk_operation_result: {
on: {
SPI_READY: {
target: 'disk_operation_wait_result',
actions: 'transferDiskOperationResult'
}
}
},
disk_operation_wait_result: {
on: {
TRANSFER_COMPLETED_OK: {
target: "not_ready"
},
TRANSFER_COMPLETED_CRC_ERROR: {
target: "not_ready"
},
TRANSFER_COMPLETED_OTHER_ERROR: {
target: "not_ready"
}
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment