Description

Loads or creates a “shared object” with the given name in the current room.

partyLoadShared() immediately returns an empty object {} which will be populated with the synced properties as soon as they are loaded from the server. The property values of the shared object are synchronized between connected clients by p5.party.

If this function is called in preload() , p5.js will wait for the shared object to load and be ready before calling setup().

Signature

partyLoadShared(name, [data], [callback])

Parameters

name

string: name of the shared object on the server, eg. shared

Loads the shared object from the server, creating a new one if it doesn’t already exist.

data (optional)

dataObject: data to initialize the shared object with, eg. {x: 0, y: 0}

The shared object is initialized with the values in the data object only if the room was empty when the current client connected. If the room already has a connected guest then the data object will be ignored.

callback (optional)

function(void): function to be called when the shared object is ready.

<aside> 🧟‍♀️ 99% of the time you won’t need to provide a callback. Normally, you call partyLoadShared() from preload() and p5 will wait for the connection to complete before calling setup().

</aside>

Returns

sharedObject: the shared object