Skip to content

Instantly share code, notes, and snippets.

@xiaojundebug
Last active April 11, 2022 09:13
Show Gist options
  • Select an option

  • Save xiaojundebug/e7a996019c3a16f26589a401109390a0 to your computer and use it in GitHub Desktop.

Select an option

Save xiaojundebug/e7a996019c3a16f26589a401109390a0 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 adValid = (context, event) => {
return !context.adSkipped
};
const machine = Machine({
"initial": "空闲中",
"context": {
"adSkipped": true
},
"states": {
"空闲中": {
"on": {
"广告": "广告中",
"直播": "直播中",
}
},
"广告中": {
"on": {
"跳过": "直播中",
"空闲": "空闲中",
}
},
"直播中": {
"on": {
"点播": "点播中",
"空闲": "空闲中",
}
},
"点播中": {
"on": {
"广告": {
"target": "广告中",
"cond": adValid
},
"直播": "直播中",
"空闲": "空闲中",
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment