indexiatech / redux-immutablejs

Redux Immutable facilities.
BSD 3-Clause "New" or "Revised" License
684 stars 36 forks source link

reducer must return immutable, how to handle js immutable types? #20

Open elaijuh opened 9 years ago

elaijuh commented 9 years ago

say i have a state like this:

{ isFetching: true, data: {foo: 'foo', bar: 'bar'}}

so how to handle in isFetching reducer?

mehiel commented 8 years ago

I think I have a similar case with redux-thunk. Can thunk work with redux-immutablejs? Even if I set enforceImmutable to false it seems to ignore the thunk middleware and just set the returned function as the new state.

tonyxiao commented 8 years ago

@elaijuh you can pass in false to the enforceImmutable key. Alternatively you can use this snippet


export const createReducer = (initialState, handlers, constructor) => {
  const enforceImmutable = Immutable.Iterable.isIterable(initialState)
  return _createReducer(initialState, handlers, enforceImmutable, constructor)
}

@indexiatech would be great if you could review.