wildlifela / redux-persist-migrate

175 stars 25 forks source link

Having trouble understanding how this works #8

Open jasan-s opened 8 years ago

jasan-s commented 8 years ago

I'm successfully using redux-persist, And I just tried deleting one of my reducers after inclusing redux-persist-migrate. However the my indexedDB still includes my deleted reducer. Is the old store supposes to get deleted ?

My code:

const manifest = {
  1: (state) => ({...state, staleReducer: undefined}),
  2: (state) => ({...state, app: {...state.app, staleKey: undefined}})
}

let reducerKey = 'app'
const migration = createMigration(manifest, reducerKey)

const historyMiddleware = routerMiddleware(browserHistory)

let reducer = combineReducers({...reducers, routing: routerReducer})
const store = createStore(
  reducer,
  compose(migration, autoRehydrate(), applyMiddleware(ReduxThunk, historyMiddleware),
   window.devToolsExtension ? window.devToolsExtension() : f => f))
rt2zz commented 7 years ago

The removed reducer does not ever actually get cleared from storage. If possible I would like to do this, but I am not certain the best way to achieve this that is not expensive (read all keys and compare).

huchenme commented 7 years ago

@rt2zz Can you help adding more examples or documentation? It is hard to understand how to use it correctly for now

ancyrweb commented 7 years ago

I agree the redux-persist-migrate documentation is hard to understand, though the concept is really important using redux-persist system.

kennethpdev commented 7 years ago

I second the motion. Need more detailed documentation, a working example would be great.

kwent commented 7 years ago

Same here. I read the README like 5 times and still don't get it.

sospedra commented 7 years ago

More examples or docs? Specially taking this comment from @Rewieer into consideration: "I agree the redux-persist-migrate documentation is hard to understand, though the concept is really important using redux-persist system."

sospedra commented 7 years ago

Hello guys, I've made this simple example:

https://github.com/sospedra/redux-persist-migrate-demo

Hope it helps. @rt2zz let me know if you want to add the example to the repo (I vouche for that!)

arvinsim commented 7 years ago

The manifest snippet of the example in the README.md file is the one that is obscure to me. I am not sure how it works.