📦 PgPubsub Spool PG Listen
Utilizes PG Listen to add a Fabrix Extension
$ npm install --save @fabrix/spool-pgpubsub
// config/main.ts
import { PgPubsubSpool } from '@fabrix/spool-pgpubsub'
export const main = {
spools: [
// ... other spools
PgPubsubSpool
]
}
// config/pgpubsub.ts
export const pgpubsub = {
}
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)