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

rehydrateAction is gone #65

Closed
totallymike opened this issue Feb 23, 2016 · 6 comments
Closed

rehydrateAction is gone #65

totallymike opened this issue Feb 23, 2016 · 6 comments

Comments

@totallymike
Copy link

It seems that the provision for a custom actionCreator has been removed at some point since v1.5.3 and v2.0.1. Is there an alternative recommendation for handing the data to be rehydrated to an action creator upon rehydration?

@rt2zz
Copy link
Owner

rt2zz commented Feb 23, 2016

What do you currently use rehydrateAction for? The recommendation is currently to do any custom rehydration processing in your reducer, or if you need to do async validation in a saga.

It was removed because in an attempt to keep the overall api and complexity limited. If you have a use case that cannot be satisfactorily handled elsewise, I would be happy to readd support.

@rt2zz
Copy link
Owner

rt2zz commented Feb 23, 2016

also fwiw in the short term you should probably stick to 1.5.3 until we have time to think over how this fits into 2.0

@totallymike
Copy link
Author

The use case that came to mind was triggering a refresh of an authentication token if the prior had expired.

@totallymike
Copy link
Author

I did end up just keeping our dependency at 1.5.3. The addition of the rehydrateAction to handle this scenario has the odd effect of persist/COMPLETE firing before the persist/REHYDRATE events, though :)

I'm rather unfamiliar with how sagas work (or what they are, in this context), but I'll do some digging. It's clear that some rearranging needs to be done.

@rt2zz
Copy link
Owner

rt2zz commented Feb 24, 2016

Ah, ok refreshing/expiring auth tokens is exactly why I added rehydrateAction in the first place! Since then however we changed how we handle auth tokens.

My recommendation is you do auth token validation in the persistStore callback:

persistStore(store, config, (err, state) => {
  if(state.auth.token) processToken(state.auth.token)
})

Thoughts?

@totallymike
Copy link
Author

That makes sense to me. I'm thinking I'm going to pull the whole auth flow out into a middleware, actually. There I can schedule the next token refresh and so on in a reasonable manner.

Thanks for all your help!

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