Skip to content

Commit

Permalink
fixes listening for deep changes on direct schema child references. b…
Browse files Browse the repository at this point in the history
…ump 0.15.0.13
  • Loading branch information
endel committed Dec 22, 2023
1 parent b18ed03 commit 0136e3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugin/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Colyseus SDK for Construct 3",
"id": "Colyseus_SDK",
"version": "0.15.0.12",
"version": "0.15.0.13",
"author": "Endel Dreyer",
"website": "https://colyseus.io/",
"documentation": "https://docs.colyseus.io",
Expand Down
5 changes: 5 additions & 0 deletions plugin/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
}

} else if (schemaType === "function") {
// "listen" on all instance fields
registerCallbacksOnStructure(schemaInstance[field], [...path, field]);

// direct schema instance
schemaInstance[field].onChange(function () {
onChangeAtPath(field, path, schemaInstance[field], undefined);
Expand All @@ -129,6 +132,7 @@
// created the schema instance
onChangeAtPath(field, path, schemaInstance[field], undefined);


} else {
// field on schema instance
schemaInstance.listen(field, function (value, previousValue) {
Expand Down Expand Up @@ -159,6 +163,7 @@
self.lastPath = self.lastCollectionPath + "." + key;
self.lastKey = key;
self.lastValue = instance;
self.Trigger(C3.Plugins.Colyseus_SDK.Cnds.OnChangeAtPath);
self.Trigger(C3.Plugins.Colyseus_SDK.Cnds.OnCollectionItemAdd);
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const PLUGIN_ID = "Colyseus_SDK";
////////////////////////////////////////////

const PLUGIN_VERSION = "0.15.0.12";
const PLUGIN_VERSION = "0.15.0.13";
const PLUGIN_CATEGORY = "web";
const PLUGIN_AUTHOR = "Endel Dreyer";

Expand Down

0 comments on commit 0136e3b

Please sign in to comment.