@arcblock/event-hub

A nodejs module for local and remote Inter Process Event

Usage no npm install needed!

<script type="module">
  import arcblockEventHub from 'https://cdn.skypack.dev/@arcblock/event-hub';
</script>

README

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
});