2.0.1 • Published 2 years ago

cyrus-rx v2.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

Cyrus

GitHub package.json version Commitizen friendly code style: prettier GitHub

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()