Description

Watches a shared object shared and calls the provided callback when any of its properties change. You can optionally provide a path on the object to watch.

Syntax

partyWatchShared(shared, [path], callback, triggerNow?)

Parameters

shared

sharedObject: the shared object to watch

path (optional)

string: a path on the shared object to watch, e.g. position.x

callback

function: the function to call when shared is updated.

receives the new value as a parameter.

triggerNow (optional)

boolean: should the callback fire immediately?

default false

Returns

nothing

Examples

Watch for any changes on shared.

let shared;
...
shared = partyLoadShared("shared");
partyWatchShared(shared, onChange);
...
function onChange(data) {
	console.log("received new data on shared!", data);
}