1 | {"version":3,"file":"network.js","sourceRoot":"","sources":["src/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;EAQE;AAEF;;;;;;;;;;;;EAYE;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,sBAAoD,EAAE,EAAE;IAC5F,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvE,sBAAsB,CAAC,SAAS,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC;AACrD,CAAC,CAAC","sourcesContent":["/**\n@license\nCopyright (c) 2018 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/**\n Utility method that calls a callback whenever the network connectivity of the app changes.\n The callback should take a boolean parameter (with `true` meaning\n the network is offline, and `false` meaning online)\n\n Example:\n\n import { installOfflineWatcher } from 'pwa-helpers/network.js';\n\n installOfflineWatcher((offline) => {\n console.log('You are ' + offline ? ' offline' : 'online');\n });\n*/\nexport const installOfflineWatcher = (offlineUpdatedCallback: (isOffline: boolean) => void) => {\n window.addEventListener('online', () => offlineUpdatedCallback(false));\n window.addEventListener('offline', () => offlineUpdatedCallback(true));\n\n offlineUpdatedCallback(navigator.onLine === false);\n};\n"]} |