@colyseus/schema 4.0.12 → 4.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/schema",
3
- "version": "4.0.12",
3
+ "version": "4.0.13",
4
4
  "description": "Binary state serializer with delta encoding for games",
5
5
  "type": "module",
6
6
  "bin": {
@@ -86,15 +86,19 @@ export class StateCallbackStrategy<TState extends IRef> {
86
86
 
87
87
  // Collection not available yet. Listen for its availability before attaching the handler.
88
88
  if (!collection || collection[$refId] === undefined) {
89
- removeHandler = this.addCallback(
89
+ let removePropertyCallback: () => void;
90
+ removePropertyCallback = this.addCallback(
90
91
  instance[$refId],
91
92
  propertyName,
92
93
  (value: TReturn, _: TReturn) => {
93
94
  if (value !== null && value !== undefined) {
95
+ // Remove the property listener now that collection is available
96
+ removePropertyCallback();
94
97
  removeHandler = this.addCallback(value[$refId], operation, handler);
95
98
  }
96
99
  }
97
100
  );
101
+ removeHandler = removePropertyCallback;
98
102
  return removeOnAdd;
99
103
 
100
104
  } else {