Skip to main content

Party

OBR.party​

The party api gives you access to other players currently in the room.

Reference

Methods​

getPlayers​

async getPlayers()

Get the other players currently in the room.

Returns an array of Players.


onChange​

onChange(callback);

Parameters

NAMETYPEDESCRIPTION
callback(players: Player[]) => voidA callback for when any connected player joins, leaves or changes

Returns a function that when called will unsubscribe from change events.

Example

/**
* Use an `onChange` event with a React `useEffect`.
* `onChange` returns an unsubscribe event to make this easy.
*/
useEffect(
() =>
OBR.party.onChange((party) => {
// React to party changes
}),
[]
);