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

Duplicate _pendingID issue #14

Open
bhoomit opened this issue May 20, 2016 · 4 comments
Open

Duplicate _pendingID issue #14

bhoomit opened this issue May 20, 2016 · 4 comments

Comments

@bhoomit
Copy link
Contributor

bhoomit commented May 20, 2016

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.

@mallison
Copy link
Contributor

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.

@bhoomit
Copy link
Contributor Author

bhoomit commented May 21, 2016

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" [email protected] 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)

@mallison
Copy link
Contributor

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 [email protected] 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" [email protected] 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)

@bhoomit
Copy link
Contributor Author

bhoomit commented Jun 14, 2016

Yes, I think that would be a better implementation.

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