Giter Club home page Giter Club logo

Comments (8)

rt2zz avatar rt2zz commented on May 18, 2024

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.

zalmoxisus avatar zalmoxisus commented on May 18, 2024

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.

rt2zz avatar rt2zz commented on May 18, 2024

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.

rt2zz avatar rt2zz commented on May 18, 2024

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.

zalmoxisus avatar zalmoxisus commented on May 18, 2024

Sure, If it is stable. Yes, as in redux-persist-crosstabs. Thanks for your help!

from redux-persist.

zalmoxisus avatar zalmoxisus commented on May 18, 2024

@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:

  1. 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.
  2. 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.

rt2zz avatar rt2zz commented on May 18, 2024

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.

zalmoxisus avatar zalmoxisus commented on May 18, 2024

That's exactly what I need. Thanks a lot!

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.