HenrikJoreteg / redux-bundler-example

Example app built with redux-bundler
34 stars 9 forks source link

Delay creation of version string until after auth #3

Open kole opened 5 years ago

kole commented 5 years ago

https://github.com/HenrikJoreteg/redux-bundler-example/blob/28a533f4fab1d05516f450475e4d4cc477d331d0/src/utils/cache.js#L9

In your example you reference this idea, but the solution is escaping me since the cacheBundle is configured on app init with the version already set.

How would I go about changing the version to include a user ID considering that data isn't available until after a user successfully authenticates?

BTW, I love redux-bundler and have decided to use it on my latest project... thanks for creating and sharing this lib!

HenrikJoreteg commented 5 years ago

Hi @kole yeah, that's a little bit of a chicken and egg problem.

I typically store auth tokens either in local storage or if doing cookie auth, create a second cookie readable from JS that is just a uuid or use shortid on npm). And all it does is get replaced whenever a new session is created.

With either method you can read that value in JS before initting your cache.