Skip to content

fabrix-app/spool-pgpubsub

Repository files navigation

spool-pgpubsub

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

Conventional Commits

📦 PgPubsub Spool PG Listen

Utilizes PG Listen to add a Fabrix Extension

Install

$ npm install --save @fabrix/spool-pgpubsub

Configure

// config/main.ts
import { PgPubsubSpool } from '@fabrix/spool-pgpubsub'
export const main = {
  spools: [
    // ... other spools
    PgPubsubSpool
  ]
}

Configuration

// config/pgpubsub.ts
export const pgpubsub = {

}

Usage

const sayHello = (payload) => {
    // Do something with Payload when an event is published to channel
    console.log(payload)
}

// Add a Channel
this.app.spools.pgpubsub.subscribe(name, sayHello)


// Publish to the Channel
this.app.spools.pgpubsub.publish(name, data)


// Completely rid the channel
this.app.spools.pgpubsub.unsubscribe(name, sayHello)