Skip to content

Instantly share code, notes, and snippets.

@oahehc
Created September 30, 2020 03:42
Show Gist options
  • Save oahehc/653a092dbb967f08d6910d64a64eb860 to your computer and use it in GitHub Desktop.
Save oahehc/653a092dbb967f08d6910d64a64eb860 to your computer and use it in GitHub Desktop.
// send message to service worker
function handleClickEven() {
worker.postMessage({ action: "skipWaiting" });
}
// receive message
self.addEventListener("message", (event) => {
if (event.data.action === "skipWaiting") {
// skip waiting to apply the new version of service worker
self.skipWaiting();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment