Skip to content

Instantly share code, notes, and snippets.

@tricinel
Created May 6, 2021 09:02
Show Gist options
  • Save tricinel/b341879eaf4254ec504c5ecacf2e35d9 to your computer and use it in GitHub Desktop.
Save tricinel/b341879eaf4254ec504c5ecacf2e35d9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const loadImageMachine = Machine({
id: 'loadImage',
initial: 'idle',
states: {
idle: {
on: {
'no-store': 'GET',
'immutable': 'check-cache',
'stale-while-invalidate': 'force-update'
}
},
GET: {
on: {
CACHE: 'cache',
NOCACHE: 'image'
}
},
'check-cache': {
on: {
NOT_FOUND: 'GET',
FOUND: 'image'
}
},
'force-update': {
on: {
YES: 'GET',
NO: 'cache'
}
},
cache: {
on: {
'': 'image'
}
},
image: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment