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 | * Subscribe to connection information. The callback is called with a parameter of type
|
28 | * [`NetInfoState`](README.md#netinfostate) whenever the connection state changes. Your listener
|
29 | * will be called with the latest information soon after you subscribe and then with any
|
30 | * subsequent changes afterwards. You should not assume that the listener is called in the same
|
31 | * way across devices or platforms.
|
32 | *
|
33 | * @param listener The listener which is called when the network state changes.
|
34 | *
|
35 | * @returns A function which can be called to unsubscribe.
|
36 | */
|
37 | export declare function addEventListener(listener: Types.NetInfoChangeHandler): Types.NetInfoSubscription;
|
38 | /**
|
39 | * A React Hook which updates when the connection state changes.
|
40 | *
|
41 | * @returns The connection state.
|
42 | */
|
43 | export declare function useNetInfo(configuration?: Partial<Types.NetInfoConfiguration>): Types.NetInfoState;
|
44 | export * from './internal/types';
|
45 | declare const _default: {
|
46 | configure: typeof configure;
|
47 | fetch: typeof fetch;
|
48 | addEventListener: typeof addEventListener;
|
49 | useNetInfo: typeof useNetInfo;
|
50 | };
|
51 | export default _default;
|