Sign in
Make Impossible States Impossible
Effects live on the edges
E
handler.ts
1
async function handleSave() {
2
send({ type: 'SAVE' })
3
try {
4
await api.save()
5
send({ type: 'SUCCESS' })
6
clearError()
7
} catch {
8
send({ type: 'FAIL' })
9
incrementRetries()
10
}
11
}
idle
saving
failed
saved