API - createCloudClient
The cloud client is responsible for authentication/sessions, observing data from a Source, and optimistically updating it.
Example usage:
import createCloudClient from "@aven-cloud/cloud/createCloudClient";
const cloud = createCloudClient({
source,
domain: 'mydomain',
});
Options
domain - the access domain of the data on the source
source - the upstream Source to access data from
initialSession - an auth session object that the client should start up with
onSession - callback to be notified of session changes, so that it can be stored.
Example with Session Saving
You may want to save the session if your client refreshes, so you won't need to log in every time. You'd do something like the following:
const initialSession = await getSession();
const cloud = createCloudClient({
source,
domain: 'mydomain',
initialSession,
onSession: session => saveSession(session)
});