"Josh Beckman", "url"=>"https://www.joshbeckman.org", "email"=>"josh@joshbeckman.org"}" />
# Dynamically Upgrade Your JS App
### Watch For a Version - Polling - Websockets - Use semver
## Watch Page Visibility ```js window.document.addEventListener('visibilitychange', () => { if (window.document.hidden) { window.alert('I will not be ignored!'); } }); ```
## Watch Input, Progress, State Guarantee reconstruction
## Watch For Downtime Are they AFK?
## Look Before You Leap ```js if (navigator.onLine) { console.log('online'); } window.addEventListener('offline', () => { console.log('offline'); }); window.addEventListener('online', () => { console.log('online'); }); ```
## Satisfied? ``` Semver Upgrade Invisible Idempotent State Downtime + Connectivity -------------- Reload! ```
## Reload API ```js // reload *from the server* window.location.reload(true); // avoid the browser cache ```
## Good Resources - [Page Visibility API - Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API) - [Location.reload() - Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload) - [Navigator.onLine - Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine)
## We're Hiring @ OfficeLuv! https://officeluv.github.io
## Thanks! https://www.andjosh.com/presents