simpleddp-node
Version:
The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments
76 lines (75 loc) • 2.11 kB
TypeScript
/**
* DDP subscription class.
*/
import DDPClient, { DDPMessage } from '../DDPClient';
export declare class ddpSubscription {
private _ddplink;
args: any[];
readonly pubname: string;
private _nosub;
private _started;
private _ready;
selfReadyEvent: {
start: () => void;
stop(): void;
};
selfNosubEvent: {
start: () => void;
stop(): void;
};
private subscriptionId;
constructor(pubname: string, args: any[], ddplink: DDPClient);
/**
* Runs everytime when `nosub` message corresponding to the subscription comes from the server.
*/
onNosub(f: (m?: DDPMessage) => void): {
start: () => void;
stop: () => void;
};
/**
* Runs everytime when `ready` message corresponding to the subscription comes from the server.
*/
onReady(f: () => void): {
start: () => void;
stop: () => void;
};
/**
* Returns true if subsciprtion is ready otherwise false.
*/
isReady(): boolean;
/**
* Returns true if subscription is stopped otherwise false.
*/
isStopped(): boolean;
/**
* Returns a promise which resolves when subscription is ready or rejects when `nosub` message arrives.
*/
ready(): Promise<void>;
/**
* Returns a promise which resolves when corresponding `nosub` message arrives.
* Rejects when `nosub` comes with error.
*/
nosub(): Promise<void>;
/**
* Returns true if subscription is active otherwise false.
*/
isOn(): boolean;
/**
* Completly removes subscription.
*/
remove(): void;
/**
* Stops subscription and return a promise which resolves when subscription is stopped.
*/
stop(): Promise<any>;
/**
* Start the subscription. Runs on class creation.
* Returns a promise which resolves when subscription is ready.
*/
start(args?: any[]): Promise<any>;
/**
* Restart the subscription. You can also change subscription arguments.
* Returns a promise which resolves when subscription is ready.
*/
restart(args?: any[]): Promise<any>;
}