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

[3.6.0-alpha1] autoRehydrate not working with immutable #165

Closed
ntucker opened this issue Sep 6, 2016 · 6 comments
Closed

[3.6.0-alpha1] autoRehydrate not working with immutable #165

ntucker opened this issue Sep 6, 2016 · 6 comments

Comments

@ntucker
Copy link

ntucker commented Sep 6, 2016

The problem is the reducer from createRehydrationReducer is only run once from the @@init action.

stateReconciler only matters INSIDE that reducer, but it doesn't even get the chance to run.

Maybe this is because I'm not using Action Buffers?

import { persistStore, autoRehydrate } from 'redux-persist'
import immutableTransform from 'redux-persist-transform-immutable'
import { stateIterator, stateGetter, stateSetter,
         stateReconciler, lastStateInit } from 'redux-persist-immutable-state'

  let enhancer = compose(
    autoRehydrate({ stateReconciler }),
    applyMiddleware(
      ...middleware,
    ),
  )

  const store = createStore(rootReducer, Map(), enhancer)
  persistStore(store, {
    whitelist: ['counter'],
    debounce: 500,
    storage: localforage,
    transforms: [immutableTransform({})],
    stateIterator,
    stateGetter, stateSetter,
    lastStateInit,
  })

As mentioned: #113 (comment)

@rt2zz
Copy link
Owner

rt2zz commented Sep 9, 2016

Afaik redux-persist-immutable-state is not yet compatible with redux-persist. You can use redux-persist2 in the meantime or wait until we launch support, hopefully next week

@ntucker
Copy link
Author

ntucker commented Sep 9, 2016

But it was merged.... #158

#113 (comment)

With that merged, what is the diff from redux-persist-2?

@rt2zz
Copy link
Owner

rt2zz commented Sep 16, 2016

Ok tentative immutable support now available at https://github.com/rt2zz/redux-persist-immutable

note I have not actually run this in an app, but the tests pass ;)

@rt2zz
Copy link
Owner

rt2zz commented Sep 16, 2016

to answer your question, it was merged with amendments. The main difference is that redux-persist-immutable wraps redux-persist rather than requiring you set the config options explicitly.

@rt2zz
Copy link
Owner

rt2zz commented Sep 18, 2016

closing as alpha version of redux-persist-immutable is now released 🎉

@rt2zz rt2zz closed this as completed Sep 18, 2016
@ntucker
Copy link
Author

ntucker commented Sep 19, 2016

Still not working for me...

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

2 participants