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

Has anyone come up with a way to update a single entity in a list? #62

Open
stueynet opened this issue Sep 18, 2018 · 1 comment
Open

Comments

@stueynet
Copy link

When you have a list of items already loaded, if one of items was updated, it seems you always have to invalidate and make the request again to the whole list of resources. This is the same for a new resource being added. So a new message comes in for example, and you have to fetch ALL messages. This is how the documentation suggests you do it but it is pretty non-performance. Particular when you want to be able to patch in updates from items within a list. You don't want to be always making the API call for a whole list of things just because one of them updated.

Anyone come up with a solution for this using bees?

@dlikhten
Copy link

dlikhten commented Aug 29, 2019

If you request a list, say /api/comments?filter[mine]=true, you can always update a single record /api/comments/10. As long as you actually select the objects from redux, you will always have the freshest data. So updating a single record will update that redux record. There is only one cannonical record for comments/10 (state.bees.entities.comments['10']) so any updates will simply update that record.

In fact, the entities grabbed from a responses' results (getRequestInfo) are mapped to the actual values in redux, so in the end you're always looking at the freshest object. The advantage of having a key-value store vs a denormalized data set (https://github.com/cantierecreativo/redux-bees/blob/master/src/selectors.js#L58).

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