This a utility for creating streams between the page and a servive worker.
pass the registered service worker to create a duplex stream.
const duplex = SwStream({ serviceWorker: this.serviceWorker.controller })
There is an optional context
property that will be passed along on the initial handshake and
retreivable from the messageEvent.data.context
received from the SwGlobalListener.
const duplex = SwStream({ serviceWorker, context })
listen for client connections
const connectionListener = new SwGlobalListener(self)
connectionListener.on('remote', (portStream, messageEvent) => {
// ...
})