Created
February 22, 2021 23:58
-
-
Save kad3nce/495a1630d66fc364b6ab2c7a9b5c1fc9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const networkStatusMachine = Machine({ | |
id: 'networkStatus', | |
initial: 'uninitialized', | |
states: { | |
uninitialized: { | |
on: { | |
// NETWORK_REQUEST_SUCCESS: 'online', | |
// NETWORK_REQUEST_ERROR: 'offline', | |
WEBSOCKET_MESSAGE_RECEIVED: 'online', | |
}, | |
}, | |
online: { | |
id: 'online', | |
on: { | |
// NETWORK_REQUEST_ERROR: 'offline', | |
WEBSOCKET_HEARTBEAT_MISSED: 'offline', | |
WEBSOCKET_CLOSED: 'offline', | |
}, | |
}, | |
offline: { | |
initial: 'WAITING', | |
states: { | |
WAITING: { | |
on: { | |
'*': { actions: 'buffer_messages_received_during_waiting_period' }, | |
}, | |
after: { | |
10000: 'ACCEPTING_EVENTS', | |
}, | |
}, | |
ACCEPTING_EVENTS: { | |
on: { | |
// NETWORK_REQUEST_SUCCESS: 'online', | |
WEBSOCKET_MESSAGE_RECEIVED: '#online', | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment