@react-native-community/netinfo
Version:
React Native Network Info API for iOS & Android
55 lines (54 loc) • 2.23 kB
TypeScript
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export declare enum NetInfoStateType {
unknown = "unknown",
none = "none",
cellular = "cellular",
wifi = "wifi",
bluetooth = "bluetooth",
ethernet = "ethernet",
wimax = "wimax",
vpn = "vpn",
other = "other"
}
export declare enum NetInfoCellularGeneration {
'2g' = "2g",
'3g' = "3g",
'4g' = "4g"
}
export interface NetInfoConnectedDetails {
isConnectionExpensive: boolean;
}
interface NetInfoConnectedState<T extends NetInfoStateType, D extends object = {}> {
type: T;
isConnected: true;
isInternetReachable: boolean | null;
details: D & NetInfoConnectedDetails;
}
interface NetInfoDisconnectedState<T extends NetInfoStateType> {
type: T;
isConnected: false;
isInternetReachable: false;
details: null;
}
export declare type NetInfoUnknownState = NetInfoDisconnectedState<NetInfoStateType.unknown>;
export declare type NetInfoNoConnectionState = NetInfoDisconnectedState<NetInfoStateType.none>;
export declare type NetInfoCellularState = NetInfoConnectedState<NetInfoStateType.cellular, {
cellularGeneration: NetInfoCellularGeneration | null;
}>;
export declare type NetInfoWifiState = NetInfoConnectedState<NetInfoStateType.wifi>;
export declare type NetInfoBluetoothState = NetInfoConnectedState<NetInfoStateType.bluetooth>;
export declare type NetInfoEthernetState = NetInfoConnectedState<NetInfoStateType.ethernet>;
export declare type NetInfoWimaxState = NetInfoConnectedState<NetInfoStateType.wimax>;
export declare type NetInfoVpnState = NetInfoConnectedState<NetInfoStateType.vpn>;
export declare type NetInfoOtherState = NetInfoConnectedState<NetInfoStateType.other>;
export declare type NetInfoState = NetInfoUnknownState | NetInfoNoConnectionState | NetInfoCellularState | NetInfoWifiState | NetInfoBluetoothState | NetInfoEthernetState | NetInfoWimaxState | NetInfoVpnState | NetInfoOtherState;
export declare type NetInfoChangeHandler = (state: NetInfoState) => void;
export declare type NetInfoSubscription = () => void;
export {};