UNPKG

insite-subscriptions-client

Version:

Client-side subscriptions/publications for inSite

67 lines 2.81 kB
import { Subscription } from "./Subscription"; import { clearSymbol, getAsInitialUpdatedSymbol, getAsUpdatesSymbol, getHandleUpdateSymbol, getSubscriptionSymbol, renewSymbol, setHandleUpdateSymbol, subscribeSymbol, unsubscribeSymbol, updateSymbol } from "./symbols"; type Item = unknown; export type Updated<I extends Item = Item> = I[] & { deleted: I[]; added: I[]; }; export type Updates<I extends Item = Item> = ([ "a", newItem: I ] | [ "d", itemToDelete: I ] | [ "i", items: I[], sort?: -1 | 0 | 1 ] | null)[] | null; export type UpdateHandler<I extends Item = Item> = (array: SubscriptionArray<I>, updated: Updated<I>, updates: Updates<I>) => void; declare const ascSort: (a: any, b: any) => 0 | 1 | -1; declare const descSort: (a: any, b: any) => 0 | 1 | -1; export declare class SubscriptionArray<I extends Item = Item> extends Array<I> { constructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>); sorted: I[]; handleUpdate: UpdateHandler<I> | undefined; sortDirection: -1 | 0 | 1; sortCompareFunction: typeof ascSort | typeof descSort | null; [getHandleUpdateSymbol](): UpdateHandler<I> | undefined; [setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>): UpdateHandler<I>; update(updates: Updates<I>): this; [updateSymbol]: (updates: Updates<I>) => this; getAsUpdates(): Updates<I>; [getAsUpdatesSymbol]: () => Updates<I>; getAsInitialUpdated(): Updated<I>; [getAsInitialUpdatedSymbol]: () => Updated<I>; clear(): void; [clearSymbol]: () => void; valueOf(): this; get [Symbol.toStringTag](): string; static updateSymbol: symbol; static getHandleUpdateSymbol: symbol; static setHandleUpdateSymbol: symbol; static getAsUpdatesSymbol: symbol; static getAsInitialUpdatedSymbol: symbol; static clearSymbol: symbol; static WithSubscription: typeof SubscriptionArrayWithSubscription; } export declare class SubscriptionArrayWithSubscription<I extends Item = Item> extends SubscriptionArray<I> { constructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately?: boolean); publicationName: string; params: unknown[]; subscription: Subscription | null; subscribe(): void; get [subscribeSymbol](): () => void; unsubscribe(): void; get [unsubscribeSymbol](): () => void; renew(publicationName?: string, params?: unknown[]): void; get [renewSymbol](): (publicationName?: string, params?: unknown[]) => void; [getSubscriptionSymbol](): Subscription | null; get [Symbol.toStringTag](): string; static subscribeSymbol: symbol; static unsubscribeSymbol: symbol; static renewSymbol: symbol; static getSubscriptionSymbol: symbol; } export {}; //# sourceMappingURL=SubscriptionArray.d.ts.map