UNPKG

659 BPlain TextView Raw
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
10import {NativeEventEmitter} from 'react-native';
11import RNCNetInfo from './nativeModule';
12import {DEVICE_CONNECTIVITY_EVENT} from './privateTypes';
13
14const nativeEventEmitter = new NativeEventEmitter();
15
16// Listen to connectivity events
17RNCNetInfo.addListener(
18 DEVICE_CONNECTIVITY_EVENT,
19 (event): void => {
20 nativeEventEmitter.emit(DEVICE_CONNECTIVITY_EVENT, event);
21 },
22);
23
24export default {
25 ...RNCNetInfo,
26 eventEmitter: nativeEventEmitter,
27};