Do we have any way to add item at the beginning of the list using EntityAdapter addOne() method #4360
Unanswered
wiktord2000
asked this question in
Q&A
Replies: 1 comment
-
The order of the properties in a map is arbitrary. I always create a selector to order the results if that is important. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For now,
addOne() by default places the item at the end of collection. I was seeking for approach to add the element at the beginning (still using EntityAdapter methods) but the only thing I came up is the following:
const { selectAll } = projectAdapter.getSelectors();
return projectAdapter.setAll([action.payload, ...selectAll(state)], state);
Instead of doing so:
return projectAdapter.addOne(action.payload, state);
Can we do it smarter? Could you create a dedicated method for that or extend the existing one to support such cases? E.g. addOneAtTheBeginning()
Beta Was this translation helpful? Give feedback.
All reactions