Skip to content

Instantly share code, notes, and snippets.

View yuulye's full-sized avatar
:octocat:
Go Mobile!

yuulye yuulye

:octocat:
Go Mobile!
View GitHub Profile
@Jonarod
Jonarod / Service_Workers_Messaging.md
Last active January 3, 2024 19:16
Describes how to send messages between a page's main thread and a service worker thread

Page to ServiceWorker

// in page.html
navigator.serviceWorker.controller.postMessage({'hello':'world'});
// in sw.js
self.addEventListener('message', event => { 
// Discord all events!
// A quick and dirty fleshing out of the discord.js event listeners (not tested at all!)
// listed here -> https://discord.js.org/#/docs/main/stable/class/Client
// Learn from this, do not just copy it mofo!
//
// Saved to -> https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584
// Last Updated -> Halloween 2022
/*