Skip to content

Latest commit

 

History

History
45 lines (26 loc) · 904 Bytes

README.md

File metadata and controls

45 lines (26 loc) · 904 Bytes

service-worker-event

An event emitter for communication between tabs using service worker.

Demo

live demo

Usage

  1. add docs/index.bundle.js in script

    <script src="./index.bundle.js"></script>
    
  2. open two tabs of the page and run these commands in console:

    swe.on('test', console.log);
    
    swe.emit('test', 'just a test.');
    

API

  1. swe.on(eventName, listener)

  2. swe.once(eventName, listener)

  3. swe.emit(eventName, payload0, payload1, payload2, ...)

  4. swe.remove(eventName, listener)

  5. swe.removeAll(eventName)

Test

run npm run build && npm run test

Benchmark

Open multi demo page and click the benchmark start button.