UNPKG

@resourge/react-fetch

Version:

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

27 lines (25 loc) 822 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 */ 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