Hi there, I'm encountering an issue while using the Colyseus framework. In my custom schema, there's an ArraySchema field marked as private, so I used the @view decorator and created a StateView for the client upon joining the room, adding this field. The problem occurs when I perform a push() operation on this ArraySchema - the client doesn't receive updates. After reviewing the documentation about view features at https://docs.colyseus.io/state/view, I noticed that for ArraySchema, each item needs to be individually added to the client's StateView. I modified my code to:
typescript
view.remove(player.gameData.cards);
view.add(player.gameData.cards);
This change made the client properly receive updates. My question is: since this field will frequently have additions and deletions, do I need to rebind it like this after every operation? Or is there a possibility that ArraySchema might be optimized in future versions? This is very important for me. Thank you so much for your help!
Hi there, I'm encountering an issue while using the Colyseus framework. In my custom schema, there's an ArraySchema field marked as private, so I used the @view decorator and created a StateView for the client upon joining the room, adding this field. The problem occurs when I perform a push() operation on this ArraySchema - the client doesn't receive updates. After reviewing the documentation about view features at https://docs.colyseus.io/state/view, I noticed that for ArraySchema, each item needs to be individually added to the client's StateView. I modified my code to:
typescript
view.remove(player.gameData.cards);
view.add(player.gameData.cards);
This change made the client properly receive updates. My question is: since this field will frequently have additions and deletions, do I need to rebind it like this after every operation? Or is there a possibility that ArraySchema might be optimized in future versions? This is very important for me. Thank you so much for your help!