My GameState has a map (MapSchema) of players (Player). Inside Player, I have a field which should be private (visible to the player and not the entire room). I am trying to use @filter, but without success.
export class SecretSchema extends Schema {
@type("number")
xyz: number;
@type("number")
abc: number;
}
export class Player extends Schema {
@filter(function(this: Player, client: any, value: GameMap, root: GameState) {
console.log("filter");
return true;
})
@type(SecretSchema)
secretVar: SecretSchema;
}
export class GameState extends Schema {
@type({ map: Player })
players = new MapSchema<Player>();
}
First, I have typescript errors on @filter. It says that Player and Schema are incompatible. But apart from that, "filter" is not printed to the console and I get the whole state on all Players in the room.