Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 622 Bytes

README.md

File metadata and controls

28 lines (21 loc) · 622 Bytes

Client Side Service Worker Ready Event

Intended to be used with sw-stream to register a service worker and provide the active service worker on a ready event

Usage

const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
const SwStream = require('sw-stream/lib/sw-stream.js')

const background = new SWcontroller({
  fileName: '/service-worker.js',
  // optional
  scope: '/',
})

background.on('ready', () => {
  let swStream = SwStream({
    serviceWorker: background.controller,
  })
 // do stuff
})

background.startWorker()