Skip to main content

Keep clients synchronized

Keep a catalog open while its view is active. The SDK verifies incoming changes before exposing them through its local data API.

Listen to changes​

Attach listeners to an already open instance. This helper forwards verified data and connection status to your view:

export function bindCatalogView(ulda, render, reportError) {
const renderCurrent = () => {
render({
status: ulda.status,
data: ulda.status === 'open' ? ulda.snapshot() : null,
});
};

const stopChanges = ulda.on('change', renderCurrent);
const stopStatus = ulda.on('status', renderCurrent);
const stopErrors = ulda.on('error', error => {
reportError(error.code);
});

renderCurrent();

return () => {
stopChanges();
stopStatus();
stopErrors();
};
}

render and reportError are application callbacks. This example hides editable data while the session is not open; an application can separately choose to display a retained offline snapshot.

The change event carries a kind and affected resource IDs, not plaintext. Read the SDK's snapshot after the event. A deletion can close the session, so check its status before reading.

SDK events​

EventWhat it tells you
changeApplication data may have changed. Kinds are updated, deleted and recovered.
statusThe session moved to a new state.
errorAn SDK error, identified by its fixed code.
reconnectRecovery progress: waiting, attempt, restored, stopped or cancelled.
traceA diagnostic summary of IDs, counts and processing steps, without plaintext.

Listener functions should be synchronous, or handle their own asynchronous failures. The SDK does not await a promise returned by a listener.

Understand session status​

StatusMeaning
connectingThe initial connection and handshake are in progress.
readyTransport is ready, but no catalog is open.
openA verified catalog is available. Individual operations can still be blocked.
disconnectedTransport is unavailable; a retained local snapshot may be readable.
reconnectingA bounded recovery attempt is running.
needsResyncAn integrity fault or unresolved operation prevents normal writes.
closedThe instance is finished. Create another instance to open a session.

Use status to drive the interface and each method's promise to track its own result.

Subscriptions are automatic​

Server Read, Create and Update operations subscribe the connection to the affected resources. A master update may introduce new content IDs; the SDK reads them using credentials from the decrypted catalog.

There is no public watch flag or per-resource unsubscribe method. The function returned by ulda.on() removes a local callback, not the server subscription. Subscriptions end with the connection and are restored by verified reads after reconnect.

Confirm your own writes​

await ulda.data.notes.text.update('Ready for tomorrow');
const confirmed = ulda.value('notes');

The writer receives an acknowledgement. Other subscribed clients receive a change notification; the server does not echo that same update back to its writer.

change is an invalidation signal, not a receipt for every local method or a durable transaction log. Reconnection restores current state through reads rather than replaying all missed events.

Close the view​

Call the listener cleanup functions when the view is disposed. When nothing else owns the SDK instance, close it:

await ulda.close();

Closing releases the session and invalidates its references. It does not delete server data.

For connection failures and uncertain writes, continue with conflicts and recovery. The lower-level transport's changed event contains ciphertext below SDK verification; it is not a replacement for the application-level change event.