GitHub | Documentation | Discord (chat) | Become a Patron

@filter not working as expected



  • 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.


  • administrator

    @emarkk filters are not working yet, they're exposed but they don't really work, I'm going to remove it in the next version until we can actually use them



  • Ok, I get it. The same goes for @nosync?


  • administrator

    @nosync is for FossilDelta only, it has no effect using the Schema serializer