@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/cjs/index.js
CHANGED
|
@@ -4146,7 +4146,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4146
4146
|
}
|
|
4147
4147
|
else {
|
|
4148
4148
|
// collection instance not received yet
|
|
4149
|
-
|
|
4149
|
+
let detachCallback = () => { };
|
|
4150
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4151
|
+
detachCallback = onAdd(ref, prop, callback, immediate && existing);
|
|
4152
|
+
});
|
|
4153
|
+
return () => detachCallback();
|
|
4150
4154
|
}
|
|
4151
4155
|
},
|
|
4152
4156
|
onChange: function onChange(callback) {
|
|
@@ -4221,19 +4225,27 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4221
4225
|
//
|
|
4222
4226
|
if (context.onInstanceAvailable) {
|
|
4223
4227
|
// collection instance not received yet
|
|
4224
|
-
|
|
4228
|
+
let detachCallback = () => { };
|
|
4229
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4230
|
+
detachCallback = onAdd(ref, callback, immediate && existing && !isTriggeringOnAdd);
|
|
4231
|
+
});
|
|
4232
|
+
return () => detachCallback();
|
|
4225
4233
|
}
|
|
4226
4234
|
else if (context.instance) {
|
|
4227
|
-
onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4235
|
+
return onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4228
4236
|
}
|
|
4229
4237
|
},
|
|
4230
4238
|
onRemove: function (callback) {
|
|
4231
4239
|
if (context.onInstanceAvailable) {
|
|
4232
4240
|
// collection instance not received yet
|
|
4233
|
-
|
|
4241
|
+
let detachCallback = () => { };
|
|
4242
|
+
context.onInstanceAvailable((ref) => {
|
|
4243
|
+
detachCallback = onRemove(ref, callback);
|
|
4244
|
+
});
|
|
4245
|
+
return () => detachCallback();
|
|
4234
4246
|
}
|
|
4235
4247
|
else if (context.instance) {
|
|
4236
|
-
onRemove(context.instance, callback);
|
|
4248
|
+
return onRemove(context.instance, callback);
|
|
4237
4249
|
}
|
|
4238
4250
|
},
|
|
4239
4251
|
}, {
|