@arcblock/event-hub

1.18.123 • Public • Published

Event Hub

A module for local and remote Inter Process Event

image

Usage

Install

yarn add @arcblock/event-hub

Server

process.env.ABT_NODE_EVENT_PORT=8888;

require('@arcblock/event-hub/lib/server.js);

Client

// process 1

const Client = require('@arcblock/event-hub/lib/client');

const port = ''; // event-hub server port
const did = ''; // your did
const sk = ''; // your sk

const client = new Client({ port, did, sk, autoConnect: true });

const data = { foo: bar };

client.broadcast('my-event', data);
// process 2

const Client = require('@arcblock/event-hub/lib/client');

const port = ''; // event-hub server port
const did = ''; // your did
const sk = ''; // your sk

const client = new Client({ port, did, sk, autoConnect: true });

client.on('my-event', (data) => {
  // handle data
});

/@arcblock/event-hub/

    Package Sidebar

    Install

    npm i @arcblock/event-hub

    Weekly Downloads

    1,228

    Version

    1.18.123

    License

    MIT

    Unpacked Size

    8.88 kB

    Total Files

    10

    Last publish

    Collaborators

    • wangshijun
    • polunzh
    • mave99a
    • gxw