Miss any of our Open RFC calls?Watch the recordings here! »

journaly

1.0.1 • Public • Published

Journaly

Publish npm version npm downloads

A simple message-broker/Pub-sub library

const function1 = async (object0, string0): Promise<string> => {
  await timeout(100);
  return new Promise((resolve) => resolve({string0: string0 + ' executed!', object0}));
};
 
const journaly = new Journaly<string>();
 
const subscribe1 = journaly.subscribe('test', function1);// Connects function1 to subject test
 
const subscribes = await Promise.all([subscribe1]);
 
// Publishes to subject test args: { someObject: 'something' }, 'test 0'
const publish1 = await journaly.publish('test', { someObject: 'something' }, 'test 0');
// Prints all responses to publish 1 from functions witch subscribe to subject test
// Each response is an element of the returned array
console.log(publish1);

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 12 or higher is required.

If this is a brand new project, make sure to create a package.json first with the npm init command or yarn init command.

Installation is done using the npm install command or yarn add command:

$ npm install journaly

or

$ yarn add journaly

Features

  • Ready to use Pub-sub design pattern
  • Promises oriented
  • Simple implementation

Object Example

class ObjectClass {
  public async method1(object0, string0): Promise<string> {
    await timeout(100);
    return new Promise((resolve) => resolve({string0: string0 + ' executed!', object0}));
  }
}
 
const object = new ObjectClass();
 
const journaly = new Journaly<string>();
 
const subscribe1 = journaly.subscribe('test', object.method1.bind(object));// Connects method1 to subject test
 
const subscribes = await Promise.all([subscribe1]);
 
// Publishes to subject test args: { someObject: 'something' }, 'test 0'
const publish1 = await journaly.publish('test', { someObject: 'something' }, 'test 0');
// Prints all responses to publish 1 from functions witch subscribe to subject test
console.log(publish1);

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

or

$ yarn
$ yarn test

People

The original author of Journaly is Judah Lima

List of all contributors

Keywords

Install

npm i journaly

DownloadsWeekly Downloads

142

Version

1.0.1

License

BSD-3-Clause

Unpacked Size

150 kB

Total Files

66

Last publish

Collaborators

  • avatar