@colyseus/schema 3.0.0-alpha.27 → 3.0.0-alpha.28
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 +5 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +5 -4
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +5 -4
- package/lib/decoder/strategy/StateCallbacks.js +5 -4
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
- package/package.json +1 -1
- package/src/decoder/strategy/StateCallbacks.ts +5 -4
package/build/cjs/index.js
CHANGED
|
@@ -4133,11 +4133,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4133
4133
|
let isCollection = ((context.instance && typeof (context.instance['forEach']) === "function") ||
|
|
4134
4134
|
(metadataOrType && typeof (metadataOrType[Symbol.metadata]) === "undefined"));
|
|
4135
4135
|
if (metadata && !isCollection) {
|
|
4136
|
-
const
|
|
4136
|
+
const onAddListen = function (ref, prop, callback, immediate) {
|
|
4137
4137
|
// immediate trigger
|
|
4138
4138
|
if (immediate &&
|
|
4139
4139
|
context.instance[prop] !== undefined &&
|
|
4140
|
-
!onAddCalls.has(
|
|
4140
|
+
!onAddCalls.has(currentOnAddCallback) // Workaround for https://github.com/colyseus/schema/issues/147
|
|
4141
4141
|
) {
|
|
4142
4142
|
callback(context.instance[prop], undefined);
|
|
4143
4143
|
}
|
|
@@ -4149,13 +4149,13 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4149
4149
|
return new Proxy({
|
|
4150
4150
|
listen: function listen(prop, callback, immediate = true) {
|
|
4151
4151
|
if (context.instance) {
|
|
4152
|
-
return
|
|
4152
|
+
return onAddListen(context.instance, prop, callback, immediate);
|
|
4153
4153
|
}
|
|
4154
4154
|
else {
|
|
4155
4155
|
// collection instance not received yet
|
|
4156
4156
|
let detachCallback = () => { };
|
|
4157
4157
|
context.onInstanceAvailable((ref, existing) => {
|
|
4158
|
-
detachCallback =
|
|
4158
|
+
detachCallback = onAddListen(ref, prop, callback, immediate && existing && !onAddCalls.has(currentOnAddCallback));
|
|
4159
4159
|
});
|
|
4160
4160
|
return () => detachCallback();
|
|
4161
4161
|
}
|
|
@@ -4224,6 +4224,7 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4224
4224
|
currentOnAddCallback = callback;
|
|
4225
4225
|
callback(value, key);
|
|
4226
4226
|
onAddCalls.delete(callback);
|
|
4227
|
+
currentOnAddCallback = undefined;
|
|
4227
4228
|
});
|
|
4228
4229
|
};
|
|
4229
4230
|
const onRemove = function (ref, callback) {
|