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

stateManager.getCollection - review / generalize options #94

Open
b-ma opened this issue Aug 5, 2024 · 2 comments
Open

stateManager.getCollection - review / generalize options #94

b-ma opened this issue Aug 5, 2024 · 2 comments

Comments

@b-ma
Copy link
Contributor

b-ma commented Aug 5, 2024

options could be:

Generalize existing parameter filtering feature (apply to SharedState and SharedCollection):

  • whitelist - same behaviour as current filter argument
  • blacklist - inverse of whitelist

Allow to model some hierarchies / relationships (apply to SharedCollection):

  • contraint - arbitrary function to filter the states that live in the collection, could be useful e.g. to model sort of simple "join"
const parent = stateManager.attach('parent');
const children = stateManager.getCollection('child', {
   constraint: values => values.parentId === parent.id
});

This could be quite simply done on the client side, just detaching early from the state if the value does not match, or even by propagating init state values in OBSERVE_NOTIFICATION to avoid additional network roundtrips.

The constraint could also be a pure facade, allowing to insert / remove a state from the collection when one of it's param changes and match the constrain... to be discussed

Maybe provide both behaviours:

  • staticContraint - check is done only on init values when the state is created (better in terms of network load)
  • liveContraint - The state is attached but added / removed from collection dynamically at any moment

Would also benefit from #93

@jipodine
Copy link
Contributor

jipodine commented Aug 8, 2024

Why not keep the whitelist (and maybe blacklist) for the subscriptions? constraint sounds more like a requirement to me. (If constraint' is to be used, do not forget the s`.)

  • dynamicWhitelist
  • staticWhitelist

Is there a way to integrate that with the filtering of attributes, to get only a subset (regardless of their values)?

@b-ma
Copy link
Contributor Author

b-ma commented Aug 8, 2024

filter rather than constraint

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

2 participants