@yorkie-js/sdk
    Preparing search index...

    Class Client

    Client is a normal client that can communicate with the server. It has documents and sends changes of the documents in local to the server to synchronize with other replicas in remote.

    Index

    Constructors

    Methods

    • activate activates this client. That is, it registers itself to the server and receives a unique ID from the server. The given ID is used to distinguish different clients.

      Returns Promise<void>

    • attach attaches a Document or Channel to this client. Overloaded to support both types.

      Type Parameters

      Parameters

      Returns Promise<Document<R, P>>

    • attach attaches the given channel to this client. It tells the server that this client will track the channel.

      Parameters

      • resource: Channel
      • Optionalopts: AttachChannelOptions

      Returns Promise<Channel>

    • attach attaches the given channel to this client. It tells the server that this client will track the channel.

      Parameters

      • channel: Channel
      • opts: AttachChannelOptions = {}

      Returns Promise<Channel>

    • broadcast broadcasts the given payload to the given topic.

      Parameters

      • key: string
      • topic: string
      • payload: any
      • Optionaloptions: BroadcastOptions

      Returns Promise<void>

    • deactivate deactivates this client.

      Parameters

      • options: DeactivateOptions = ...

        If keepalive is true, the client will request deactivation immediately using fetch with the keepalive option enabled. This is useful for ensuring the deactivation request completes even if the page is being unloaded, such as in beforeunload or unload event listeners. If synchronous is true, the server will wait for all pending operations to complete before deactivating.

      Returns Promise<void>

    • detach detaches a Document or Channel from this client. Overloaded to support both types.

      Type Parameters

      Parameters

      • resource: Document<R, P>
      • Optionalopts: { keepalive?: boolean; removeIfNotAttached?: boolean }

      Returns Promise<Document<R, P>>

    • detach detaches the given channel from this client. It tells the server that this client will no longer track the channel.

      Parameters

      Returns Promise<Channel>

    • detachChannel detaches the given channel from this client. It tells the server that this client will no longer track the channel.

      Parameters

      Returns Promise<Channel>

    • getID returns a ActorID of client.

      Returns string | undefined

    • has checks if the given resource is attached to this client.

      Parameters

      • key: string

        the key of the resource.

      Returns boolean

      true if the resource is attached to this client.

    • isActive checks if the client is active.

      Returns boolean

    • restoreRevision restores the document to the given revision.

      Type Parameters

      Parameters

      Returns Promise<void>

    • sync pushes local changes of the attached documents to the server and receives changes of the remote replica from the server then apply them to local documents.

      For Channel in manual mode, it refreshes the TTL by sending a heartbeat.

      Type Parameters

      Parameters

      Returns Promise<Document<R, P>[]>

    • sync refreshes the TTL of the given channel by sending a heartbeat. This is used for manual mode channel.

      Parameters

      Returns Promise<Channel>