UNPKG

@graphile/subscriptions-lds

Version:

Subscriptions plugin for PostGraphile using PostgreSQL logicial decoding

38 lines (37 loc) 1.2 kB
import { Plugin } from "postgraphile-core"; declare type SubscriptionReleaser = () => void; declare type Predicate = (record: any) => boolean; export declare class LDSLiveSource { readonly slotName: string | null; private lds; private url; private connectionString; private reconnecting; private live; private subscriptions; private ws; private sleepDuration?; private tablePattern?; /** * @param url - If not specified, we'll spawn our own LDS listener */ constructor(options: Options); init(): Promise<void>; subscribeCollection(callback: () => void, collectionIdentifier: any, predicate?: Predicate): SubscriptionReleaser | null; subscribeRecord(callback: () => void, collectionIdentifier: any, recordIdentifier: any): SubscriptionReleaser | null; close(): Promise<void>; private connect; private reconnect; private sub; private announce; private handleAnnouncement; private handleMessage; } interface Options { ldsURL?: string; connectionString?: string; sleepDuration?: number; tablePattern?: string; } declare const PgLDSSourcePlugin: Plugin; export default PgLDSSourcePlugin;