1 | /**
|
2 | * Copyright (c) Facebook, Inc. and its affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | * @format
|
8 | */
|
9 | import * as Types from './internal/types';
|
10 | /**
|
11 | * Configures the library with the given configuration. Note that calling this will stop all
|
12 | * previously added listeners from being called again. It is best to call this right when your
|
13 | * application is started to avoid issues.
|
14 | *
|
15 | * @param configuration The new configuration to set.
|
16 | */
|
17 | export declare function configure(configuration: Partial<Types.NetInfoConfiguration>): void;
|
18 | /**
|
19 | * Returns a `Promise` that resolves to a `NetInfoState` object.
|
20 | *
|
21 | * @param [requestedInterface] interface from which to obtain the information
|
22 | *
|
23 | * @returns A Promise which contains the current connection state.
|
24 | */
|
25 | export declare function fetch(requestedInterface?: string): Promise<Types.NetInfoState>;
|
26 | /**
|
27 | * Force-refreshes the internal state of the NetInfo library.
|
28 | *
|
29 | * @returns A Promise which contains the updated connection state.
|
30 | */
|
31 | export declare function refresh(): Promise<Types.NetInfoState>;
|
32 | /**
|
33 | * Subscribe to connection information. The callback is called with a parameter of type
|
34 | * [`NetInfoState`](README.md#netinfostate) whenever the connection state changes. Your listener
|
35 | * will be called with the latest information soon after you subscribe and then with any
|
36 | * subsequent changes afterwards. You should not assume that the listener is called in the same
|
37 | * way across devices or platforms.
|
38 | *
|
39 | * @param listener The listener which is called when the network state changes.
|
40 | *
|
41 | * @returns A function which can be called to unsubscribe.
|
42 | */
|
43 | export declare function addEventListener(listener: Types.NetInfoChangeHandler): Types.NetInfoSubscription;
|
44 | /**
|
45 | * A React Hook which updates when the connection state changes.
|
46 | *
|
47 | * @returns The connection state.
|
48 | */
|
49 | export declare function useNetInfo(configuration?: Partial<Types.NetInfoConfiguration>): Types.NetInfoState;
|
50 | export * from './internal/types';
|
51 | declare const _default: {
|
52 | configure: typeof configure;
|
53 | fetch: typeof fetch;
|
54 | refresh: typeof refresh;
|
55 | addEventListener: typeof addEventListener;
|
56 | useNetInfo: typeof useNetInfo;
|
57 | };
|
58 | export default _default;
|