UNPKG

@resourge/react-fetch

Version:

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

34 lines (31 loc) 759 B
/** * react-fetch v1.41.3 * * Copyright (c) resourge. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import NetInfo from '@react-native-community/netinfo'; const globalState = { current: true }; NetInfo.fetch().then(state => { globalState.current = Boolean(state.isConnected); }); function OnlineGetSnapshot() { return globalState.current; } function OnlineSubscribe(callback) { const remove = NetInfo.addEventListener(state => { globalState.current = state.isConnected === true; callback(); }); return () => { remove(); }; } export { OnlineGetSnapshot, OnlineSubscribe }; //# sourceMappingURL=OnlineUtils.native.js.map