@colyseus/schema 3.0.7 → 3.0.9

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.
@@ -4630,7 +4630,10 @@ function getDecoderStateCallbacks(decoder) {
4630
4630
  }
4631
4631
  },
4632
4632
  onRemove: function (callback) {
4633
- if (context.onInstanceAvailable) {
4633
+ if (context.instance) {
4634
+ return onRemove(context.instance, callback);
4635
+ }
4636
+ else if (context.onInstanceAvailable) {
4634
4637
  // collection instance not received yet
4635
4638
  let detachCallback = () => { };
4636
4639
  context.onInstanceAvailable((ref) => {
@@ -4638,12 +4641,12 @@ function getDecoderStateCallbacks(decoder) {
4638
4641
  });
4639
4642
  return () => detachCallback();
4640
4643
  }
4641
- else if (context.instance) {
4642
- return onRemove(context.instance, callback);
4643
- }
4644
4644
  },
4645
4645
  onChange: function (callback) {
4646
- if (context.onInstanceAvailable) {
4646
+ if (context.instance) {
4647
+ return onChange(context.instance, callback);
4648
+ }
4649
+ else if (context.onInstanceAvailable) {
4647
4650
  // collection instance not received yet
4648
4651
  let detachCallback = () => { };
4649
4652
  context.onInstanceAvailable((ref) => {
@@ -4651,9 +4654,6 @@ function getDecoderStateCallbacks(decoder) {
4651
4654
  });
4652
4655
  return () => detachCallback();
4653
4656
  }
4654
- else if (context.instance) {
4655
- return onChange(context.instance, callback);
4656
- }
4657
4657
  },
4658
4658
  }, {
4659
4659
  get(target, prop) {