Git Product home page Git Product logo

Comments (6)

rt2zz avatar rt2zz commented on May 18, 2024

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.

from redux-persist.

rt2zz avatar rt2zz commented on May 18, 2024

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

from redux-persist.

totallymike avatar totallymike commented on May 18, 2024

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

from redux-persist.

totallymike avatar totallymike commented on May 18, 2024

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.

from redux-persist.

rt2zz avatar rt2zz commented on May 18, 2024

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?

from redux-persist.

totallymike avatar totallymike commented on May 18, 2024

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!

from redux-persist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.