0.0.6 • Published 5 years ago

r1-ext-hub v0.0.6

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

R1 Web Extension Hub

This library implements an event bus or hub to talk to R1 Web Extensions and receive requests from that.

Quickstart

  1. npm install r1-ext-hub or download dist/r1-ext-hub.js (which is a UMD module)
  2. import * as r1HubExt from 'r1-ext-hub' or <script src="r1-ext-hub"> which adds a globalr1ExtHub`
  3. Register subscriptions to the hub: const api = r1ExtHub.register({getUserInfo: () => Promise.resolve(someUserInfo), ... }) See API doc for events that the Extension might be sending. Make sure you return a Promise object from this handlers
  4. Get ready to receive callbacks from the Extension. Send lifecycle events like api.broadcast({r1ExEvent: "processingStart

Simulator

A bare-bones ReplyOne Desk simulator is available in simulator/simulator.html

Open it using an HTTP server. If you need one on a whim, run this in the root directory. python -m SimpleHTTPServer

In the simulator, enter the URL of the Extension (which also needs to be served by a HTTP server), click on Set. The Extension will be loaded and is expected to register with the simulator (per r1Ext.register)

Click Start Processing to simulate a processingStart event. Click other buttons as you see fit.

Build

npm run build

Two artifacts are generated in dist: dist/index.es.js to use with CommonJS module loaders as well as dist/r1-extension.js which is a UMD module, i.e. you can load it with a simple <script> tag. In that case, a new global symbol r1Ext is available

Run tests

npm run test

Build interactively

npm run watch

Documentation

npm run docs

Documentation is available in /docs

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago