@resourge/react-fetch
Version:
[](LICENSE)
27 lines (25 loc) • 822 B
JavaScript
/**
* react-fetch v1.43.1
*
* 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
*/
function OnlineGetSnapshot() {
return typeof globalThis.navigator !== 'undefined' ? globalThis.navigator.onLine : true;
}
const OnlineSubscribe = typeof globalThis.window !== 'undefined' && typeof globalThis.window.addEventListener !== 'undefined' ? callback => {
window.addEventListener('online', callback);
window.addEventListener('offline', callback);
return () => {
window.removeEventListener('online', callback);
window.removeEventListener('offline', callback);
};
} : () => {
return () => {};
};
export { OnlineGetSnapshot, OnlineSubscribe };
//# sourceMappingURL=OnlineUtils.js.map