Package Exports
- journaly
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (journaly) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Journaly
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