async record(pollyRequest) { pollyRequest.action = ACTIONS.RECORD; if ('navigator' in global && !navigator.onLine) { console.warn( '[Polly] Recording may fail because the browser is offline.\n' + `${stringifyRequest(pollyRequest)}` ); } return this.onRecord(pollyRequest); }
const useConnectivityListener = () => { const [isOnline, setIsOnline] = useState(window ? window.navigator.onLine : false);
if ( navigator.onLine ) { startCalypso();
/** * Checks whether the browser running this code has internet access. * This function will always return true in the node.js environment * * @api private */ function isOnline() { let online = true; if (typeof window !== "undefined" && "navigator" in window && window.navigator.onLine === false) { online = false; } return online; }
$("#check").on('click',function(){ if (navigator.onLine) { console.log('Online'); set_online(); } else { console.log('Offline'); set_offline(); } });
const listenNetworkState = () => (dispatch) => { const networkListener = () => { dispatch(networkStateChanged({ isOnline: navigator.onLine })); }; window.addEventListener('online', networkListener); window.addEventListener('offline', networkListener); networkListener(); }
componentDidMount(){ if (navigator.onLine) { this.props.fetchUser() } else { this.props.loadHabitsBrowser() this.props.loadNotesBrowser() } }
componentDidMount() { if (!navigator.onLine) { this.restoreStateFromLocalStorage(); } this.getPriceForDay(0, "todayprice"); this.getPriceForDay(1, "yesterdayprice"); this.getPriceForDay(2, "twodaysprice"); this.getPriceForDay(3, "threedaysprice"); this.getPriceForDay(4, "fourdaysprice"); }
// Subscribe to 'native' online/offline events function onStatusChange(evt) { type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE; // force async setTimeout(function(){ cordova.fireDocumentEvent(evt.type); },0); }
render () { let appStatus = (navigator.onLine) ? 'Online!': 'Offline :('; return ( <header className="site-header"> <div className="status">{appStatus}</div> <h1>Video Listing</h1> <a href="#">Refresh</a> </header> ) }
componentDidMount() { if (navigator.onLine) { this.getData(); } else { this.getOfflineData(); // showNotification("Connection not available but keep calm we're PWA"); } }
function viaNavigatorInitial() { if (navigator.onLine) { connectionStatus.innerHTML = "connected"; } else { connectionStatus.innerHTML = "no connection"; } }
async record(pollyRequest) { pollyRequest.action = ACTIONS.RECORD; if ('navigator' in global && !navigator.onLine) { console.warn( '[Polly] Recording may fail because the browser is offline.\n' + `${stringifyRequest(pollyRequest)}` ); } return this.onRecord(pollyRequest); }
const useConnectivityListener = () => { const [isOnline, setIsOnline] = useState(window ? window.navigator.onLine : false);