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'
});
A. $ npm install fxos-components/bridge
B. $ bower install fxos-components/bridge
C. Copy/paste
Window: <script src="bridge.js">
Worker: importScripts('bridge.js')
View documentationWhen possible use lighter
client.js
orservice.js