jamesplease / redux-resource

3kb resource management for Redux
https://redux-resource.js.org
MIT License
237 stars 28 forks source link

Support add item at top for lists #444

Closed tomzaku closed 4 years ago

tomzaku commented 4 years ago

I would like to add ids at the beginning of the list.

{
            resources: [item],
            list: questionId,
            unshiftList: true
}

Correct me if I'm doing wrong

jamesplease commented 4 years ago

Thanks for the PR, @tomzaku ! I’m not currently interested in adding this functionality (though I could be convinced 😜 .

The problem is that right now, you want it at the start of a list. Later, somebody will want it in the middle of a list. Somebody else might want it 2nd in the list. Then somebody will want the list to remain sorted. And then, for somebody else, the sort will be too slow, so they will want it to be cached.

It’s not possible to replace the full functionality that JS provides with a declarative API, and I intentionally want to avoid moving in that direction.

If I could go back in time, I would actually remove the push() and make it so that lists are always outright replaced by actions, so that you would need to completely manage them yourself, outside of redux-resource.

If you need help crafting the code to do this, let me know and I’d be happy to help you out with that! For now, I’m going to close out this issue.