Kvoti / redux-rest

Automatically create Redux action constants, action creators, and reducers for your REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate _pendingID issue

bhoomit opened this issue · comments

I'm using redux-localstorage to retain store state between page refreshes. In which case ActionCreators will get "reinitialize" and the default _pendingID will reset to 0. Because of this I have duplicate pending ids in the redux store and it causes the issue in getting the latest state from the store.

I have a quick fix for this. But I want to get your opinion on this issue.

What's your idea?

At a quick glance I was thinking we could put that id in the store as action creators can call getState then the pending action reducer can increment it. Not completely sure that'd work.

Let me think about your idea. My idea is basically set the default pending
Id to current timestamp. That would make sure it's never a duplicate.
On May 21, 2016 15:27, "Mark Allison" notifications@github.com wrote:

What's your idea?

At a quick glance I was thinking we could put that id in the store as
action creators can call getState then the pending action reducer can
increment it. Not completely sure that'd work.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#14 (comment)

That would work too.

I wonder if it'd be better to be able to specify a field that's unique for
each endpoint. That way you could match up the ajax response to the pending
item without the need for the _pendingID. It'd also let you do more
advanced things like check if there's already a request in-flight for/with
the same data. For a GET on a collection endpoint you don't need an ID as
you'd only ever want one such request active.

On 21 May 2016 at 11:34, Bhoomit notifications@github.com wrote:

Let me think about your idea. My idea is basically set the default pending
Id to current timestamp. That would make sure it's never a duplicate.
On May 21, 2016 15:27, "Mark Allison" notifications@github.com wrote:

What's your idea?

At a quick glance I was thinking we could put that id in the store as
action creators can call getState then the pending action reducer can
increment it. Not completely sure that'd work.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#14 (comment)


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#14 (comment)

Yes, I think that would be a better implementation.