Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying filter to a non primitive property still creates an empty collection on the client #125

Open
WesleyClements opened this issue Mar 18, 2022 · 0 comments

Comments

@WesleyClements
Copy link

WesleyClements commented Mar 18, 2022

The code I have is something along the lines of

class SubSchema extends Schema {...}
class State extends Schema {
  constructor() {
    super();
    this.activePlayerIndex = 0;
    this.playerIds= new ArraySchema("1", "2", "3");
    this.playerState= new SubSchema ({ a: 1, b: 2, c: 3);
  }
}

const types = {
  activePlayerIndex : 'number',
  playerIds: ['string'],
  playerState: SubSchema,
};
defineTypes(GameState, types);

filter(function() { return false; })(State.prototype, "activePlayerIndex");
filter(function() { return false; })(State.prototype, "playerIds");
filter(function() { return false; })(State.prototype, "playerState");

I'm expecting that the state on the client to be something like

{}

but instead I'm getting

{
  playerIds: [],
  playerState: {}
}

From everything I can find, it seems like I'm using everything properly but you'll have to let me know.
I would like to hide the property names in addition to the elements of the collection.
I see the value in restricting info about the server implementation specifics.
I could achieve this by not annotating types for those properties but that restricts the usefulness of any presence in use.
After looking into this, it may just be a result of the schema serialization not taking filters into account.
This might be fixed by adding an annotation like @internal to notate fields that are only meant for the server.

@WesleyClements WesleyClements changed the title Applying filter to a non primitive property still sends an empty collection to the client Applying filter to a non primitive property still creates an empty collection on the client Apr 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant