yorkie-js-sdk

Home > yorkie-js-sdk > Client

Client class

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.

Signature:

export declare class Client<M = Indexable> implements Observable<ClientEvent<M>> 

Implements: Observable<ClientEvent<M>>

Constructors

Constructor Modifiers Description
(constructor)(rpcAddr, opts)   Constructs a new instance of the Client class

Methods

Method Modifiers Description
activate()   ativate activates this client. That is, it register itself to the server and receives a unique ID from the server. The given ID is used to distinguish different clients.
attach(doc, isManualSync)   attach attaches the given document to this client. It tells the server that this client will synchronize the given document.
deactivate()   deactivate deactivates this client.
detach(doc)   detach detaches the given document from this client. It tells the server that this client will no longer synchronize the given document.To collect garbage things like CRDT tombstones left on the document, all the changes should be applied to other replicas before GC time. For this, if the document is no longer used by this client, it should be detached.
getID()   getID returns a ActorID of client.
getKey()   getKey returns a key of client.
getPeers(key)   getPeers returns the peers of the given document.
getPresence()   getPresence returns the presence of this client.
getStatus()   getStatus returns the status of this client.
isActive()   isActive checks if the client is active.
subscribe(nextOrObserver, error, complete)   subscribe subscribes to the given topics.
sync()   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.
updatePresence(key, value)   updatePresence updates the presence of this client.