Comments (8)
Woops, I forgot to update the recipes: I renamed it to rehydrateAction
persistStore(store, { rehydrateAction: rehydrateAction })
Note: your rehydrateAction must use the import { REHYDRATE } from 'redux-persist/constants'
action type if you want autoRehydrate to pick it up.
I also removed it from the docs because I am not yet sure if this is the best api for taking action during rehydration. Are you making server calls within your custom rehydrate action? Let me know if it works well for you.
from redux-persist.
It works now. Thanks a lot!
Just testing so far. Trying to replace browser extension messaging with just rehydratations. As the result we get a crossbrowser (only the Storage Backend will be different) extension with just redux actions. It seems to be pretty suitable for Chrome, but still have to implement some hacks for Firefox and to check how stable it will be. Maybe it is a crazy idea, but worth to try :)
from redux-persist.
awesome, let me know how it goes, or if you need any additional integration points into redux-persist to make it work.
from redux-persist.
not sure I fully understand your architechture, but you might consider calling persistor.rehydrate to keep things in sync between tabs
const persistor = persistStore(store)
//...
persistor.rehydrate(someReducerKey, newState, () => {})
from redux-persist.
Sure, If it is stable. Yes, as in redux-persist-crosstabs. Thanks for your help!
from redux-persist.
@rt2zz, as I promised, here are the results of this "experiment": https://github.com/zalmoxisus/browser-redux.
It uses chrome.store as described in your documentation. Synchronisation is made as in persist-croostab.
It seems to work pretty well. The only differences from using redux-persist on web apps are:
- Unlike window.addEventListener('storage'), chrome.storage.onChanged is triggered on local changes as well, which is reported as a bug. But it can be managed trivially.
- chrome.storage.local can store objects, so we don't need to serialize the data (in order to boost the performance), though we still need it to fix 1.
from redux-persist.
that looks awesome.
Regarding serialization, redux-persist serializes the data before calling the storage api. I did add an undocumented escape hatch where you can specify a serialize and deserialize function in the config:
persistStore(store, { serialize: (data) => data, deserialize: (data) => data })
from redux-persist.
That's exactly what I need. Thanks a lot!
from redux-persist.
Related Issues (20)
- Jest snapshot is always created as null in react native
- Persist not working after page reload or refresh HOT 3
- failed to preserved initial state value at rehydrate
- PersistGate in SSR applications rendering app twice when using React v18 HOT 3
- Documentation for Migration is unnecessary complicated. HOT 1
- Getting got unexpected undefined error while changing redux state HOT 1
- getting error: A non-serializable value was detected in an action HOT 5
- createStore() is old
- Clear Redux Persist Data on App uninstall in IOS React Native HOT 1
- Support for Redux v5 and RTK v2 HOT 10
- state is null HOT 1
- data migration security and automatization
- Redux persist not working with RN 0.73 HOT 10
- Move project to new repo? HOT 13
- redux-persist failed to create sync storage. falling back to noop storage | Next js HOT 3
- Vitest - The slice reducer for key "reducer name" returned undefined during initialization
- Option to disable storage creation error for dynamic stores
- storage.getItem is not a function (it is undefined) - RN 0.73.4 HOT 3
- Redux persist getting cleared after persisting PatientsReducers
- Dead link for config object of persistReducer function.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-persist.