/
actions.js
42 lines (38 loc) · 1018 Bytes
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// @flow
import { SET_NETWORK_INFO, _STORE_NETWORK_INFO_CLEANUP } from './actionTypes';
import type { NetworkInfo } from './types';
/**
* Up[dates the network info state.
*
* @param {NetworkInfo} networkInfo - The new network state to be set.
* @returns {{
* type: SET_NETWORK_INFO,
* isOnline: boolean,
* networkType: string,
* details: Object
* }}
*/
export function setNetworkInfo({ isOnline, networkType, details }: NetworkInfo): Object {
return {
type: SET_NETWORK_INFO,
isOnline,
networkType,
details
};
}
/**
* Stored the cleanup function used to shutdown the {@code NetworkInfoService}.
*
* @param {Function} cleanup - The cleanup function to be called on {@code APP_WILL_UNMOUNT}.
* @returns {{
* type: _STORE_NETWORK_INFO_CLEANUP,
* cleanup: Function
* }}
* @private
*/
export function _storeNetworkInfoCleanup(cleanup: Function): Object {
return {
type: _STORE_NETWORK_INFO_CLEANUP,
cleanup
};
}