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