@colyseus/schema 3.0.0-alpha.23 → 3.0.0-alpha.24
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/cjs/index.js +17 -5
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +17 -5
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +17 -5
- package/lib/decoder/strategy/StateCallbacks.d.ts +8 -4
- package/lib/decoder/strategy/StateCallbacks.js +17 -5
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
- package/package.json +1 -1
- package/src/decoder/strategy/StateCallbacks.ts +31 -12
package/build/esm/index.mjs
CHANGED
|
@@ -4144,7 +4144,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4144
4144
|
}
|
|
4145
4145
|
else {
|
|
4146
4146
|
// collection instance not received yet
|
|
4147
|
-
|
|
4147
|
+
let detachCallback = () => { };
|
|
4148
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4149
|
+
detachCallback = onAdd(ref, prop, callback, immediate && existing);
|
|
4150
|
+
});
|
|
4151
|
+
return () => detachCallback();
|
|
4148
4152
|
}
|
|
4149
4153
|
},
|
|
4150
4154
|
onChange: function onChange(callback) {
|
|
@@ -4219,19 +4223,27 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4219
4223
|
//
|
|
4220
4224
|
if (context.onInstanceAvailable) {
|
|
4221
4225
|
// collection instance not received yet
|
|
4222
|
-
|
|
4226
|
+
let detachCallback = () => { };
|
|
4227
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4228
|
+
detachCallback = onAdd(ref, callback, immediate && existing && !isTriggeringOnAdd);
|
|
4229
|
+
});
|
|
4230
|
+
return () => detachCallback();
|
|
4223
4231
|
}
|
|
4224
4232
|
else if (context.instance) {
|
|
4225
|
-
onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4233
|
+
return onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4226
4234
|
}
|
|
4227
4235
|
},
|
|
4228
4236
|
onRemove: function (callback) {
|
|
4229
4237
|
if (context.onInstanceAvailable) {
|
|
4230
4238
|
// collection instance not received yet
|
|
4231
|
-
|
|
4239
|
+
let detachCallback = () => { };
|
|
4240
|
+
context.onInstanceAvailable((ref) => {
|
|
4241
|
+
detachCallback = onRemove(ref, callback);
|
|
4242
|
+
});
|
|
4243
|
+
return () => detachCallback();
|
|
4232
4244
|
}
|
|
4233
4245
|
else if (context.instance) {
|
|
4234
|
-
onRemove(context.instance, callback);
|
|
4246
|
+
return onRemove(context.instance, callback);
|
|
4235
4247
|
}
|
|
4236
4248
|
},
|
|
4237
4249
|
}, {
|