@resourge/react-fetch
Version:
[](LICENSE)
34 lines (31 loc) • 759 B
JavaScript
/**
* 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