-
Notifications
You must be signed in to change notification settings - Fork 866
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
Takes time to persist the store in AsyncStorage #720
Comments
This should not be the case. The delay should be something like a few ms. How many reducers do you have? Also have you set a |
I've only persisted a single reducer using
In the enhancers I mostly have dev tools and saga middleware. |
@alexmngn did you resolve this issue? |
I found throttle's implementation to be different from what the documentation states. Throttle actually slows down the processing of modified keys in the state rather than throttling the write. I found this code in So if you have large throttle value and if the state keeps updating, I believe it may even lead to starvation. For the current implementation, I suggest keeping throttle to a really low value like 5 or 10 ms. @rt2zz How about having a synchronous function to process the modified keys, and then trigger the write to the storage. We should throttle this function. Ideally, it should be a mix of throttle and debounce. Keep calling this function once every X ms (throttle) on state update and if there are any modified keys since the last persist and more than some Y ms (debounce) has passed, call the function again. The idea is similar to |
Just a note but I do not believe this is limited to AsyncStorage. Trying to use a throttle of any value on a regular web app with localStorage causes updated state to be ignored in persistence, even after manually calling |
@ozzyogkush: There are few bugs around persistence. I found two and fixed them but this project is running late with merging pull requests. See #811. |
Just a friendly reminder that I realized that the state hasn't changed as I was doing something like:
As the persistReducer would only do a shallow compare, the above case would be missed out for persistence. I was too stupid to spend many days thinking this is the problem with the library. But yeah, double check the code. |
I recently updated to 6.0 and noticed that the initial persistence is really slow (6 seconds). Did anyone find a solution? Seems throttle is not working as expected? |
I solved my scenario here #786 |
I use redux-persist on a React-Native app.
I noticed it takes about 20 seconds before my store gets stored in the AsyncStorage. If I restart my app in less than that, the REHYDRATE restores the old version of the store. I'm wondering why is this so long? Is there a delay? Can it be customized? AsyncStorage is pretty fast on its own.
Thanks
The text was updated successfully, but these errors were encountered: