bindJoinableSpaces (Javascript)
- Declaration
public bindJoinableSpaces(spaceConnection: CavrnusSpaceConnection, spaceAdded: (s: CavrnusSpace) => void, spaceUpdated: (s: CavrnusSpace) => void, spaceRemoved: (s: CavrnusSpace) => void): Hook
- Description
Triggers when joinable spaces become available, or when their metadata changes.
When called, you will immediately get spaceAdded
events for all spaces currently in your list.
- Sample
import { CavrnusSpatialConnector } from "../services/csc";
const csc = new CavrnusSpatialConnector();
const spaceUsers: CavrnusSpace[] = [];
async function bindJoinableSpaces()
{
try
{
await csc.authenticateAsGuest("https://cav.dev.cavrn.us", "guest");
const spaceConnection = await csc.joinSpace(roomId.value);
hooks.value.push(csc.bindJoinableSpaces(spaceConnection, v => {spaceUsers.push(v);}, v=> {}, v => {spaceUsers.splice(spaceUsers.indexOf(v), 1);});
}
catch (err)
{
throw err;
}
}