@colyseus/schema 4.0.9 → 4.0.11
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/package.json
CHANGED
|
@@ -85,7 +85,7 @@ export class StateCallbackStrategy<TState extends IRef> {
|
|
|
85
85
|
const collection = (instance as any)[propertyName] as TReturn;
|
|
86
86
|
|
|
87
87
|
// Collection not available yet. Listen for its availability before attaching the handler.
|
|
88
|
-
if (collection
|
|
88
|
+
if (!collection || collection[$refId] === undefined) {
|
|
89
89
|
removeHandler = this.addCallback(
|
|
90
90
|
instance[$refId],
|
|
91
91
|
propertyName,
|
|
@@ -485,11 +485,13 @@ export const Callbacks = {
|
|
|
485
485
|
* @param roomOrDecoder - Room or Decoder instance to get the callbacks for.
|
|
486
486
|
* @returns the new callbacks standard API.
|
|
487
487
|
*/
|
|
488
|
-
get<T extends IRef>(
|
|
488
|
+
get<T extends IRef>(
|
|
489
|
+
roomOrDecoder: Decoder<T> | { serializer: { decoder: Decoder<T> } } | { state: T; serializer: object }
|
|
490
|
+
): StateCallbackStrategy<T> {
|
|
489
491
|
if (roomOrDecoder instanceof Decoder) {
|
|
490
492
|
return new StateCallbackStrategy<T>(roomOrDecoder);
|
|
491
493
|
|
|
492
|
-
} else if (roomOrDecoder.serializer
|
|
494
|
+
} else if ('decoder' in roomOrDecoder.serializer) {
|
|
493
495
|
return new StateCallbackStrategy<T>(roomOrDecoder.serializer.decoder);
|
|
494
496
|
|
|
495
497
|
} else {
|
|
@@ -505,11 +507,13 @@ export const Callbacks = {
|
|
|
505
507
|
* @param roomOrDecoder - Room or Decoder instance to get the legacy callbacks for.
|
|
506
508
|
* @returns the legacy callbacks API.
|
|
507
509
|
*/
|
|
508
|
-
getLegacy<T extends Schema>(
|
|
510
|
+
getLegacy<T extends Schema>(
|
|
511
|
+
roomOrDecoder: Decoder<T> | { serializer: { decoder: Decoder<T> } } | { state: T; serializer: object }
|
|
512
|
+
): SchemaCallbackProxy<T> {
|
|
509
513
|
if (roomOrDecoder instanceof Decoder) {
|
|
510
514
|
return getDecoderStateCallbacks(roomOrDecoder);
|
|
511
515
|
|
|
512
|
-
} else if (roomOrDecoder.serializer
|
|
516
|
+
} else if ('decoder' in roomOrDecoder.serializer) {
|
|
513
517
|
return getDecoderStateCallbacks(roomOrDecoder.serializer.decoder);
|
|
514
518
|
}
|
|
515
519
|
},
|