kuzzle-sdk
Version:
Official Javascript SDK for Kuzzle
52 lines (51 loc) • 1.48 kB
TypeScript
import type { ArgsRealtimeControllerSubscribe, RealtimeController } from "../controllers/Realtime";
import type { JSONObject, Notification } from "../types";
type SubscribeResponse = {
result: {
channel: string;
roomId: string;
};
};
type RoomOptions = ArgsRealtimeControllerSubscribe & {
autoResubscribe?: boolean;
state?: string;
};
type SubscribeRequest = {
action: "subscribe";
body: JSONObject;
collection: string;
controller: "realtime";
index: string;
scope?: RoomOptions["scope"];
state?: RoomOptions["state"];
users?: RoomOptions["users"];
volatile?: RoomOptions["volatile"];
};
type RoomCallback = (notification: Notification) => void | Promise<void>;
declare class Room {
controller: RealtimeController;
index: string;
collection: string;
callback: RoomCallback;
options: RoomOptions;
id: string;
channel: string;
request: SubscribeRequest;
autoResubscribe: boolean;
subscribeToSelf: boolean;
private _kuzzle;
/**
* @param controller
* @param index
* @param collection
* @param body
* @param callback
* @param options
*/
constructor(controller: RealtimeController, index: string, collection: string, body: JSONObject, callback: RoomCallback, options?: RoomOptions);
get kuzzle(): any;
subscribe(): Promise<SubscribeResponse>;
removeListeners(): void;
private _channelListener;
}
export default Room;