@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/build/index.cjs CHANGED
@@ -5196,11 +5196,15 @@ class StateCallbackStrategy {
5196
5196
  const collection = instance[propertyName];
5197
5197
  // Collection not available yet. Listen for its availability before attaching the handler.
5198
5198
  if (!collection || collection[$refId] === undefined) {
5199
- removeHandler = this.addCallback(instance[$refId], propertyName, (value, _) => {
5199
+ let removePropertyCallback;
5200
+ removePropertyCallback = this.addCallback(instance[$refId], propertyName, (value, _) => {
5200
5201
  if (value !== null && value !== undefined) {
5202
+ // Remove the property listener now that collection is available
5203
+ removePropertyCallback();
5201
5204
  removeHandler = this.addCallback(value[$refId], operation, handler);
5202
5205
  }
5203
5206
  });
5207
+ removeHandler = removePropertyCallback;
5204
5208
  return removeOnAdd;
5205
5209
  }
5206
5210
  else {