r1-ext-hub
v0.0.6
Published
Internal library to talk to R1 Web Extensions from within the ReplyOne UI
Downloads
7
Readme
R1 Web Extension Hub
This library implements an event bus or hub to talk to R1 Web Extensions and receive requests from that.
Quickstart
npm install r1-ext-hub
or downloaddist/r1-ext-hub.js
(which is a UMD module)import * as r1HubExt from 'r1-ext-hub'
or<script src="r1-ext-hub"> which adds a global
r1ExtHub`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 handlersGet 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