Installation & Basic Usage
Installation
Below is an installation example using deep-equal.
Preparation
runnel
requires two dependencies to be installed.
Dependency #1: Deep Equal
The first dependency is used to compare two objects and requires the following interface:
deep-equal and lodash.isequal are good libraries for this.
Dependency #2: JSON Schema Validator
The second dependency validates payloads against a JSON Schema. The interface is as follows:
You can use the package @runnel/validator for this purpose.
Please read Make Your Own Validator if you need a customized validator.
Usage
- Initialize an event bus with
createEventBus
which returnsregisterTopic
.
import { runnel } from "runneljs";
import deepEqual from "deep-equal";
import { validator } from "@runnel/validator";
const { registerTopic } = runnel("my-event-bus", deepEqual, validator);
- Create an event topic.
- Publish and subscribe to events using the topic.