StateView.remove() behaves differently than I expected #852
-
Hi, I'm building a Colyseus-based card game where cards change visibility depending on gameplay:
To achieve this, I use export class CardPublic extends Schema {
@view() @type("string") cardId: string;
@type("string") zone: string;
@type("number") index: number;
} export class BoardState extends Schema {
@type({ map: CardPublic }) cards = new MapSchema();
} All cards are pre-populated in ObservationOn the client, I set up the following listeners for verification: $(room.state).cards.onAdd((card, id) => {
$(card).listen("cardId", (value, preValue) => {
console.log("cardId changed!!:", value, preValue);
});
});
$(room.state).cards.onRemove((card, id) => {
console.log("Card removed:", id);
});
This results in a From the client's point of view, the card appears to have been completely removed from the state, even though it was only meant to become partially hidden (via QuestionWhat I originally expected from
Given that calling If there's a recommended way to implement that kind of behavior, I'd greatly appreciate any guidance. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @nishiyamaan, thank you for the detailed feedback. The behaviour you described is not the intended behaviour indeed. I've just created a test case covering this, and fixed it on this commit: colyseus/schema@f1d46b9 Please let me know if upgrading |
Beta Was this translation helpful? Give feedback.
Hi @nishiyamaan, thank you for the detailed feedback. The behaviour you described is not the intended behaviour indeed. I've just created a test case covering this, and fixed it on this commit: colyseus/schema@f1d46b9
Please let me know if upgrading
@colyseus/schema
fixes this issue for you. Cheers!