cyrus-rx
v2.0.1
Published
PubSub library using Rxjs and Postgres Notify-Listen
Downloads
3
Maintainers
Readme
Cyrus
Pubsub library for Postgres.
Install
npm install cyrus-rx
Usage
Options
- appName (required): string
- name of the application (used for logging)
- user (optional): string
- option for Postgres Pool Connection
- password (optional): string
- option for Postgres Pool Connection
- host (optional): string
- option for Postgres Pool Connection
- port (optional): number
- option for Postgres Pool Connection
- database (optional): string
- option for Postgres Pool Connection
import cyrus from 'cyrus-rx';
const notifier = cyrus({ appName: 'cyrus-example' });
// It needs to be connected before used
const connectedSuccessfully = await notifier.connect();
if (connectedSuccessfully) {
// Create an observable to with a channel to listen to
// Rx.Observable
const observable$ = notifier.on('example-channel');
// Sends this to postgres
// The observable will emit this message.
notifier.notify('example-channel', 'example-message');
}
// disconnect from the database by ending the pool
notifier.disconnect()