UNPKG

partysync

Version:

Experimental library to synchronize state between a Durable Object and client. See [design discussion](https://github.com/cloudflare/partykit/issues/147).

31 lines (29 loc) 805 B
import { Connection, Server, WSMessage } from "partyserver"; //#region src/server/index.d.ts type ActionType = { type: string; payload: unknown; }; type RecordType = unknown[]; type Channels = { [Channel: string]: { record: RecordType; action: ActionType; }; }; declare class SyncServer< Env extends Cloudflare.Env = Cloudflare.Env, TChannels extends Channels = Channels > extends Server<Env> { static options: { hibernate: boolean; }; onAction<Channel extends keyof TChannels>( channel: Channel, action: TChannels[typeof channel]["action"] ): TChannels[Channel]["record"][] | Promise<TChannels[Channel]["record"][]>; onMessage(connection: Connection, message: WSMessage): Promise<void>; } //#endregion export { SyncServer }; //# sourceMappingURL=index.d.ts.map