Skip to content

fxos-components/bridge

Repository files navigation

bridge.js

Exposes a service between one browser JavaScript context to another.

// my-worker.js:

service('my-service')
  .method('greet', name => 'hello ' + name)
  .listen();
// app.js:

var endpoint = new Worker('my-worker.js');
var myClient = client('my-service', endpoint);

myClient.method('greet', 'john').then(value => {
  console.log(value); //=> 'hello john'
});

Install options

A. $ npm install fxos-components/bridge
B. $ bower install fxos-components/bridge
C. Copy/paste

Usage

Window: <script src="bridge.js">
Worker: importScripts('bridge.js')

When possible use lighter client.js or service.js

Documentation

View documentation