fxos-components / bridge

Exposes services between JavaScript contexts
https://fxos-components.github.io/bridge
MIT License
20 stars 8 forks source link

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="https://github.com/fxos-components/bridge/raw/master/bridge.js">
Worker: importScripts('bridge.js')

When possible use lighter client.js or service.js

Documentation

View documentation