Created
April 7, 2016 16:52
-
-
Save benfoxall/eaa56b5f71fa67c39511ac3ebdd54cbf to your computer and use it in GitHub Desktop.
Service Worker page refresh thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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