@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/esm/index.mjs
CHANGED
|
@@ -4131,11 +4131,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4131
4131
|
let isCollection = ((context.instance && typeof (context.instance['forEach']) === "function") ||
|
|
4132
4132
|
(metadataOrType && typeof (metadataOrType[Symbol.metadata]) === "undefined"));
|
|
4133
4133
|
if (metadata && !isCollection) {
|
|
4134
|
-
const
|
|
4134
|
+
const onAddListen = function (ref, prop, callback, immediate) {
|
|
4135
4135
|
// immediate trigger
|
|
4136
4136
|
if (immediate &&
|
|
4137
4137
|
context.instance[prop] !== undefined &&
|
|
4138
|
-
!onAddCalls.has(
|
|
4138
|
+
!onAddCalls.has(currentOnAddCallback) // Workaround for https://github.com/colyseus/schema/issues/147
|
|
4139
4139
|
) {
|
|
4140
4140
|
callback(context.instance[prop], undefined);
|
|
4141
4141
|
}
|
|
@@ -4147,13 +4147,13 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4147
4147
|
return new Proxy({
|
|
4148
4148
|
listen: function listen(prop, callback, immediate = true) {
|
|
4149
4149
|
if (context.instance) {
|
|
4150
|
-
return
|
|
4150
|
+
return onAddListen(context.instance, prop, callback, immediate);
|
|
4151
4151
|
}
|
|
4152
4152
|
else {
|
|
4153
4153
|
// collection instance not received yet
|
|
4154
4154
|
let detachCallback = () => { };
|
|
4155
4155
|
context.onInstanceAvailable((ref, existing) => {
|
|
4156
|
-
detachCallback =
|
|
4156
|
+
detachCallback = onAddListen(ref, prop, callback, immediate && existing && !onAddCalls.has(currentOnAddCallback));
|
|
4157
4157
|
});
|
|
4158
4158
|
return () => detachCallback();
|
|
4159
4159
|
}
|
|
@@ -4222,6 +4222,7 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4222
4222
|
currentOnAddCallback = callback;
|
|
4223
4223
|
callback(value, key);
|
|
4224
4224
|
onAddCalls.delete(callback);
|
|
4225
|
+
currentOnAddCallback = undefined;
|
|
4225
4226
|
});
|
|
4226
4227
|
};
|
|
4227
4228
|
const onRemove = function (ref, callback) {
|