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.
partyWatchShared(shared, [path], callback, triggerNow?)
sharedObject: the shared object to watch
string: a path on the shared object to watch, e.g. position.x
function: the function to call when shared is updated.
receives the new value as a parameter.
boolean: should the callback fire immediately?
default false
nothing
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);
}