mysql-live
Version:
Brings the server.publish and client.subscribe for live updates on mysql database. The only one Live Collections.
46 lines (45 loc) • 1.93 kB
TypeScript
import { Collection } from "./Collection";
import Handler from "./Handler";
export declare type AnyPublicationArgs = CallbackSubscriptionType | Cursor[] | Cursor | Collection | Collection[];
export declare type CallbackSubscriptionType = (...args: any[]) => Cursor | Cursor[];
export interface PublicationsDictionary {
[name: string]: AnyPublicationArgs;
}
export interface SubscriptionsDictionary {
[name: string]: Subscription[];
}
export interface Subscription {
name: string;
subscriber: string;
cursor: Cursor;
}
export declare type Cursor = FindCursor | ProcedureCursor;
export interface FindCursor {
collectionName: string;
criteria: any;
__find__: boolean;
}
export interface ProcedureCursor {
name: string;
params: any[];
__procedure__: boolean;
canInsert?: (newItem: any) => boolean;
collectionNames: string[];
}
export declare class LiveStore {
private handler;
publications: PublicationsDictionary;
subscriptions: SubscriptionsDictionary;
constructor(handler: Handler);
isFindCursor(cursor: any): cursor is FindCursor;
isProcedureCursor(cursor: any): cursor is ProcedureCursor;
registerPublication(publicationName: string, subscriptionCb: AnyPublicationArgs): void;
registerSubscriptions(socketId: string, subscriptionName: string, ...clientArgs: any[]): Subscription[];
getSubscriptionsByCollection(collectionName: string): Subscription[];
getSubscriptionsByProcedure(procedureName: string): Subscription[];
getSubscriptionByCollectionAndSubscriber(socketId: string, collectionName: string): Subscription;
removeAllSubscriptionsBySubscriber(socketId: string): void;
removeSubscriptionByNameAndSubscriber(socketId: string, subscriptionName: string): void;
isSubscribedToCollection(socketId: string, collectionName: string): boolean;
isSubscribedTo(socketId: string, subscriptionName: string): boolean;
}