“myShared” Objects

Description

Returns the current client’s shared object

<aside> 🧟

Using p5.js 2? p5.js 2 doesn't have preload(). Instead, call partyConnect() and partyLoadShared() in an async setup() and await them. See the p5.js 2 Quick Start Guide.

</aside>

To get an array of shared objects corresponding to the room’s current guests use partyLoadGuestShareds().

If a guest’s shared object is empty (it has no properties) it will NOT be included in the GuestShareds array. It will appear in the array as soon as a property is added to it.

This is sometimes useful if you want a client to connect but “lurk” until ready to join.

If you want your shared object to appear on the GuestShared’s array immediately, provide a non-empty object as the data argument.

Syntax

partyLoadMyShared([data], [callback])

Parameters

data (optional)

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

callback (optional)

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

Returns

p5.js 1: sharedObject: the shared object

p5.js 2: a Promise that resolves to the shared object once it is ready