Hello everybody. I have two questions about resetting callbacks for state changes for data based on schema:
#1
Set onChange
callback for collection of primitive types based on schema:
https://docs.colyseus.io/state/schema/#onchange-instance-key
room.state.players.onChange = (player, key) => {
console.log(player, "have changes at", key);
};
Question: How to reset that callback? Is the following correct?
room.state.players.onChange = undefined;
#2
Set listen
callback on single property based on schema:
https://docs.colyseus.io/state/schema/#listenprop-callback
state.listen("currentTurn", (currentValue, previousValue) => {
console.log(`currentTurn is now ${currentValue}`);
console.log(`previous value was: ${previousValue}`);
});
Question: How to reset that callback? The following does not work (at least not in TypeScript)!
state.listen("currentTurn", undefined); // compiler error, at least in TypeScript
P.S.:
Plenty other features of Colyseus work really fine for me. 👍