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

Pagination support #22

Open
qiuwei opened this issue Feb 24, 2016 · 5 comments
Open

Pagination support #22

qiuwei opened this issue Feb 24, 2016 · 5 comments
Labels

Comments

@qiuwei
Copy link

qiuwei commented Feb 24, 2016

I am developing an application with pagination support.

It seems that after an ITEMS_FETCH_SUCCESS is dispatched, the base reducer merges the newly fetched ITEMS into the old state.

Why is it designed like this? Do I need to override this behavior to implement pagination?

@sporto
Copy link
Contributor

sporto commented Feb 28, 2016

Yes, ITEMS_FETCH_SUCCESS adds the newly fetched to the old ones. We think that having one collection with all the items is better than splitting them. For example if you want to do calculations or search is just easier by looking at one place.

To do paginations I suggest storing the pagination information somewhere else. You could have an object that stores the current page, maybe the first id and last ids on that page or something like that. I haven't had the need to implement pagination, so I don't have a very concrete answer.

@MarkMurphy
Copy link

I've just done this. See https://gist.github.com/MarkMurphy/9b964b3cfa7b30736734e6a908b3a6b4

It's inefficient however because redux-crud stores records as an array instead of as a map. This means that you have filter over all of your records instead of plucking them out of a map by their key. See the implementation in the link above for examples.

I ended up creating my own fork of redux-crud and modifying it to use maps instead of arrays.

@luisfuertes
Copy link

luisfuertes commented Nov 30, 2016

I cant save the total length of items in redux-crud reducer state, and cant replace items in list, only add news.

This component doesnt works with lists..

@TrejGun
Copy link
Contributor

TrejGun commented Feb 2, 2017

Hi there!
very good lib but indeed lacks support of pagination

for example I'd like to have simple list with pagination so my BE returns

{total:100,list:[...]}

there is no place for me to store total so i have to do 2 calls to server

and another example is when
I'm doing two calls to server
/list?x=1 and /list?x=2
results are merged into one array
can you store search options + returned ids in weak map ?
so i can get this result from cache next time

@TrejGun
Copy link
Contributor

TrejGun commented Feb 2, 2017

you actually have what i mean in
https://github.com/Versent/redux-loader
is it possible to combine this two libs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants