Download spectrum/src/reducers/connectionStatus.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/reducers/connectionStatus.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/reducers/connectionStatus.js
-
curl -L -o connectionStatus.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/reducers/connectionStatus.js
835 Bytes
| // @flow | |
| export type WebsocketConnectionType = | |
| | 'connected' | |
| | 'connecting' | |
| | 'reconnected' | |
| | 'reconnecting'; | |
| type InitialState = { | |
| networkOnline: boolean, | |
| websocketConnection: WebsocketConnectionType, | |
| }; | |
| type ActionType = { | |
| type: 'NETWORK_CONNECTION' | 'WEBSOCKET_CONNECTION' | 'PAGE_VISIBILITY', | |
| value: any, | |
| }; | |
| const initialState: InitialState = { | |
| networkOnline: true, | |
| websocketConnection: 'connected', | |
| }; | |
| export default function status( | |
| state: InitialState = initialState, | |
| action: ActionType | |
| ) { | |
| switch (action.type) { | |
| case 'NETWORK_CONNECTION': | |
| return Object.assign({}, state, { | |
| networkOnline: action.value, | |
| }); | |
| case 'WEBSOCKET_CONNECTION': | |
| return Object.assign({}, state, { | |
| websocketConnection: action.value, | |
| }); | |
| default: | |
| return state; | |
| } | |
| } | |