Vaultrice SDK - v0.9.11
    Preparing search index...

    Interface SyncObjectMeta

    Metadata for a SyncObject.

    interface SyncObjectMeta {
        id: string;
        joinedConnections: JoinedConnections;
        join: (data: JSONObj) => Promise<undefined>;
        leave: () => Promise<undefined>;
        send: (
            msg: JSONObj,
            options?: { transport?: "ws" | "http" },
        ) => Promise<undefined>;
        on: {
            (event: "connect", handler: () => void): any;
            (event: "disconnect", handler: () => void): any;
            (
                event: "presence:join",
                handler: (joinedConnection: JoinedConnection) => void,
            ): any;
            (
                event: "presence:leave",
                handler: (leavedConnection: LeavedConnection) => void,
            ): any;
            (event: "message", handler: (data: JSONObj) => void): any;
            (event: "error", handler: (error: Error) => void): any;
            (
                event: "setItem",
                handler: (
                    item: { value: ValueType } & SetReturnType & { prop: string },
                ) => void,
            ): any;
            (
                event: "setItem",
                name: string,
                handler: (
                    item: { value: ValueType } & SetReturnType & { prop: string },
                ) => void,
            ): any;
            (event: "removeItem", handler: (item: { prop: string }) => void): any;
            (
                event: "removeItem",
                name: string,
                handler: (item: { prop: string }) => void,
            ): any;
            (
                event: string,
                handlerOrName:
                    | string
                    | (
                        (
                            item: { value: ValueType } & SetReturnType & { prop: string },
                        ) => void
                    )
                    | ((name: string) => void)
                    | (() => void)
                    | ((error: Error) => void)
                    | ((data: JSONObj) => void)
                    | ((joinedConnection: JoinedConnection) => void)
                    | ((leavedConnection: LeavedConnection) => void),
                handler?:
                    | (
                        (
                            item: { value: ValueType } & SetReturnType & { prop: string },
                        ) => void
                    )
                    | (() => void)
                    | ((name: string) => void)
                    | ((error: Error) => void)
                    | ((data: JSONObj) => void),
            ): any;
        };
        off: {
            (event: "connect", handler: () => void): any;
            (event: "disconnect", handler: () => void): any;
            (
                event: "presence:join",
                handler: (joinedConnection: JoinedConnection) => void,
            ): any;
            (
                event: "presence:leave",
                handler: (leavedConnection: LeavedConnection) => void,
            ): any;
            (event: "message", handler: (data: JSONObj) => void): any;
            (event: "error", handler: (error: Error) => void): any;
            (
                event: "setItem",
                handler: (
                    item: { value: ValueType } & SetReturnType & { prop: string },
                ) => void,
            ): any;
            (
                event: "setItem",
                name: string,
                handler: (
                    item: { value: ValueType } & SetReturnType & { prop: string },
                ) => void,
            ): any;
            (event: "removeItem", handler: (item: { prop: string }) => void): any;
            (
                event: "removeItem",
                name: string,
                handler: (item: { prop: string }) => void,
            ): any;
            (
                event: string,
                handlerOrName:
                    | string
                    | (
                        (
                            item: { value: ValueType } & SetReturnType & { prop: string },
                        ) => void
                    )
                    | ((name: string) => void)
                    | (() => void)
                    | ((error: Error) => void)
                    | ((data: JSONObj) => void)
                    | ((joinedConnection: JoinedConnection) => void)
                    | ((leavedConnection: LeavedConnection) => void),
                handler?:
                    | (
                        (
                            item: { value: ValueType } & SetReturnType & { prop: string },
                        ) => void
                    )
                    | (() => void)
                    | ((name: string) => void)
                    | ((error: Error) => void)
                    | ((data: JSONObj) => void),
            ): any;
        };
        useAccessToken: (accessToken: string) => void;
        onAccessTokenExpiring: (handler: () => void) => void;
        offAccessTokenExpiring: (handler: () => void) => void;
        connect: () => Promise<void>;
        disconnect: () => Promise<void>;
        isConnected: boolean;
    }
    Index

    Properties

    id: string

    The unique identifier for the SyncObject.

    joinedConnections: JoinedConnections

    List of currently joined connections.

    join: (data: JSONObj) => Promise<undefined>

    Join the presence channel with custom data.

    leave: () => Promise<undefined>

    Leave the presence channel.

    send: (
        msg: JSONObj,
        options?: { transport?: "ws" | "http" },
    ) => Promise<undefined>

    Send a message to other clients.

    on: {
        (event: "connect", handler: () => void): any;
        (event: "disconnect", handler: () => void): any;
        (
            event: "presence:join",
            handler: (joinedConnection: JoinedConnection) => void,
        ): any;
        (
            event: "presence:leave",
            handler: (leavedConnection: LeavedConnection) => void,
        ): any;
        (event: "message", handler: (data: JSONObj) => void): any;
        (event: "error", handler: (error: Error) => void): any;
        (
            event: "setItem",
            handler: (
                item: { value: ValueType } & SetReturnType & { prop: string },
            ) => void,
        ): any;
        (
            event: "setItem",
            name: string,
            handler: (
                item: { value: ValueType } & SetReturnType & { prop: string },
            ) => void,
        ): any;
        (event: "removeItem", handler: (item: { prop: string }) => void): any;
        (
            event: "removeItem",
            name: string,
            handler: (item: { prop: string }) => void,
        ): any;
        (
            event: string,
            handlerOrName:
                | string
                | (
                    (
                        item: { value: ValueType } & SetReturnType & { prop: string },
                    ) => void
                )
                | ((name: string) => void)
                | (() => void)
                | ((error: Error) => void)
                | ((data: JSONObj) => void)
                | ((joinedConnection: JoinedConnection) => void)
                | ((leavedConnection: LeavedConnection) => void),
            handler?:
                | (
                    (
                        item: { value: ValueType } & SetReturnType & { prop: string },
                    ) => void
                )
                | (() => void)
                | ((name: string) => void)
                | ((error: Error) => void)
                | ((data: JSONObj) => void),
        ): any;
    }

    Register an event handler.

    off: {
        (event: "connect", handler: () => void): any;
        (event: "disconnect", handler: () => void): any;
        (
            event: "presence:join",
            handler: (joinedConnection: JoinedConnection) => void,
        ): any;
        (
            event: "presence:leave",
            handler: (leavedConnection: LeavedConnection) => void,
        ): any;
        (event: "message", handler: (data: JSONObj) => void): any;
        (event: "error", handler: (error: Error) => void): any;
        (
            event: "setItem",
            handler: (
                item: { value: ValueType } & SetReturnType & { prop: string },
            ) => void,
        ): any;
        (
            event: "setItem",
            name: string,
            handler: (
                item: { value: ValueType } & SetReturnType & { prop: string },
            ) => void,
        ): any;
        (event: "removeItem", handler: (item: { prop: string }) => void): any;
        (
            event: "removeItem",
            name: string,
            handler: (item: { prop: string }) => void,
        ): any;
        (
            event: string,
            handlerOrName:
                | string
                | (
                    (
                        item: { value: ValueType } & SetReturnType & { prop: string },
                    ) => void
                )
                | ((name: string) => void)
                | (() => void)
                | ((error: Error) => void)
                | ((data: JSONObj) => void)
                | ((joinedConnection: JoinedConnection) => void)
                | ((leavedConnection: LeavedConnection) => void),
            handler?:
                | (
                    (
                        item: { value: ValueType } & SetReturnType & { prop: string },
                    ) => void
                )
                | (() => void)
                | ((name: string) => void)
                | ((error: Error) => void)
                | ((data: JSONObj) => void),
        ): any;
    }

    Unregister an event handler.

    useAccessToken: (accessToken: string) => void

    Set a new access token for authentication.

    onAccessTokenExpiring: (handler: () => void) => void

    Register a handler for access token expiring events.

    offAccessTokenExpiring: (handler: () => void) => void

    Unregister a handler for access token expiring events.

    connect: () => Promise<void>

    Manually connect the SyncObject.

    disconnect: () => Promise<void>

    Manually disconnect the SyncObject.

    isConnected: boolean

    Indicates if the SyncObject is currently connected.