Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created April 7, 2016 16:52
Show Gist options
  • Save benfoxall/eaa56b5f71fa67c39511ac3ebdd54cbf to your computer and use it in GitHub Desktop.
Save benfoxall/eaa56b5f71fa67c39511ac3ebdd54cbf to your computer and use it in GitHub Desktop.
Service Worker page refresh thing
importScripts('pusher-iso-worker.js')
var pusher = new Pusher('key-here', {disableStats: true})
pusher
.subscribe('live_load')
.bind('uploaded', (data) => {
self.clients.matchAll()
.then((clients) => {
clients.forEach((client) => {
client.postMessage(data.file);
})
})
})
navigator.serviceWorker.register('sw.js')
navigator.serviceWorker.addEventListener('message', _ => location.reload())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment