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

Handle errors #1

Closed
gaearon opened this issue Jul 23, 2015 · 4 comments
Closed

Handle errors #1

gaearon opened this issue Jul 23, 2015 · 4 comments

Comments

@gaearon
Copy link

gaearon commented Jul 23, 2015

Be careful with localStorage! The data might get corrupted or something, so try/catch is a good idea.
Worse, iOS in private mode will throw on every .setItem or .getItem call.

@rt2zz
Copy link
Owner

rt2zz commented Jul 24, 2015

Added try/catch, thanks.

I am still trying to figure out a decent api for persisting state. One function with 4 (mostly optional) arguments is clumsy. Also having to add a rehydrate action handler per reducer can be tedious and error prone.

@rt2zz rt2zz closed this as completed Jul 24, 2015
@gaearon
Copy link
Author

gaearon commented Jul 24, 2015

Why not rehydrate by providing the initial state? For example that's how persistState works.

@rt2zz
Copy link
Owner

rt2zz commented Jul 24, 2015

@gaearon a few things:

  • support async storage api's (e.g. react-native)
  • allow for performance optimizations in the future, perhaps web workers for parsing
  • reducers can conditionally or partially rehydrate. E.G. a reducer might refuse data based on an expiry date.
  • All of the other fluxy benefits, e.g. make debugging easy and explicit. If a rehydration is causing problems one can easily trace it back to the action.

I implemented pluggable storage last night in order to support react-native. New API:

const config = {
  blacklist: ['someReducer'], 
  actionCreator:rehydrate,
  storage: AsyncStorage,
}
persistStore(store, config, () => {
  console.log('restored')
})

dtschust added a commit to dtschust/redux-persist that referenced this issue Aug 27, 2018
@ksairi
Copy link

ksairi commented Oct 4, 2018

@rt2zz how can I catch an error, i.e of no space in disk, while the persist action is happening in a react native app?

andrewlmurray pushed a commit to iamsoberapp/redux-persist that referenced this issue May 17, 2022
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

3 participants