Listening for Client Updates

PSPDFKit Instant comes with an additional set of APIs to utilize the power of real-time collaboration. This includes an API to receive updates whenever new clients connect to a document, as well as an API to access all currently connected clients.

Both methods return an Immutable.Map of InstantClients:

instance.connectedClients.count(); // => 12

instance.addEventListener(
  "instant.connectedClients.change",
  (clients) => {
    console.log(clients.toJS());
  }
);
instance.connectedClients.count(); // => 12

instance.addEventListener(
  "instant.connectedClients.change",
  function (clients) {
    console.log(clients.toJS());
  }
);

Disable the Clients Presence API

The Clients Presence API requires a single WebSocket that is kept active while the instance of PSPDFKit for Web is loaded.

If you don’t wish to use this API, you can prevent this WebSocket connection by setting clientsPresenceEnabled in the Instant settings object to false:

PSPDFKit.load({
    instant: {
        clientsPresenceEnabled: false
    },
    ...
});
PSPDFKit.load({
    instant: {
        clientsPresenceEnabled: false
    },
    ...
});