RealtimeStore – JavaScript
The RealtimeStore, a property of the Meeting Class, allows you to set, get, and listen to value changes for specific keys shared across all participants in a meeting.
It provides a simple key–value storage system that stays synchronized in real time among all connected participants.
Methods
setValue()
The setValue() method is used to store or update data in the Realtime Store. If a key already exists, it will be overwritten with the new value. Passing null as the value deletes the key.
Parameters
key(string) – The unique key under which the data will be stored.value(string | null) – The value to be stored. Passnullto delete the key.
Returns
Promise<void>- Throws an error if:
- Key or value is missing or not of type string.
- Payload size exceeds 1 KB per key.
- Session exceeds the 100-key limit.
- Request fails due to network or internal issues.
Example
try {
await meeting.realtimeStore.setValue("Blocked_Students", "[Halima, Rajan]");
console.log("Data set successfully!");
} catch (error) {
console.error("Failed to set data:", error);
}
getValue()
The getValue() method retrieves the current value associated with a given key from the Realtime Store.
Parameters
key(string) – The key whose value you want to retrieve.
Returns
Promise<string | null>— The stored value, ornullif the key does not exist or retrieval fails.
- Throws an error if:
- Key is missing or not of type string.
- Request fails due to network or internal issues.
Example
try {
const value = await meeting.realtimeStore.getValue("Blocked_Students");
console.log("Current value:", value);
} catch (error) {
console.error("Failed to get data:", error);
}
observe()
The observe() method subscribes to real-time updates for a given key.
When the value of that key changes, the provided callback function is triggered automatically for all participants.
Parameters
-
key(string) – The key to observe for changes. -
callback(function) – Function triggered on each update. Receives:value(string | null) – The new value ornullif deleted.updatedBy(string) – The participant ID of the participant who updated the value.
Returns
Promise<string>— The unique observer ID.
Example
try {
const observerId = await meeting.realtimeStore.observe(
"Blocked_Students",
(value, updatedBy) => {
console.log("Value updated:", value, "by", updatedBy);
}
);
} catch (error) {
console.error("Failed to observe key:", error);
}
stopObserving()
The stopObserving() method stops receiving updates for a previously observed key using its observer ID.
Parameters
observerId(string) – The observer ID returned from theobserve()method.
Returns
Promise<void>
Example
try {
await meeting.realtimeStore.stopObserving(observerId);
console.log("Stopped observing successfully!");
} catch (error) {
console.error("Failed to stop observing:", error);
}
Got a Question? Ask us on discord

