journaly
A simple pub-sub library project
Last updated 8 days ago by judahh .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install journaly 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.0                                ...           latest (8 days ago)

17 Versions

  • 2.0.0                                ...           8 days ago
  • 1.0.1                                ...           2 months ago
  • 1.0.0                                ...           6 months ago
  • 0.1.5                                ...           6 months ago
  • 0.1.4                                ...           6 months ago
  • 0.1.3                                ...           8 months ago
  • 0.1.2                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           10 months ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 21
Last Day 0
Last Week 20
Last Month 1
Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |