1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import {NetInfoState} from './types';
|
11 |
|
12 | export const DEVICE_CONNECTIVITY_EVENT = 'netInfo.networkStatusDidChange';
|
13 |
|
14 |
|
15 | export type NetInfoNativeModuleState = Pick<
|
16 | NetInfoState,
|
17 | Exclude<keyof NetInfoState, 'isInternetReachable'>
|
18 | > & {isInternetReachable?: boolean};
|
19 |
|
20 | export interface Events {
|
21 | [DEVICE_CONNECTIVITY_EVENT]: NetInfoNativeModuleState;
|
22 | }
|
23 |
|
24 | export interface NetInfoNativeModule {
|
25 | getCurrentState: (
|
26 | requestedInterface?: string,
|
27 | ) => Promise<NetInfoNativeModuleState>;
|
28 | addListener<K extends keyof Events>(
|
29 | type: K,
|
30 | listener: (event: Events[K]) => void,
|
31 | ): void;
|
32 | removeListeners<K extends keyof Events>(
|
33 | type: K,
|
34 | listener: (event: Events[K]) => void,
|
35 | ): void;
|
36 | }
|
37 |
|
38 | export type NetInfoInternetReachabilityChangeListener = (
|
39 | isInternetReachable: boolean | null | undefined,
|
40 | ) => void;
|