Use immer
This commit is contained in:
parent
7f755d2a83
commit
4f72e164d7
33 changed files with 1236 additions and 1153 deletions
|
@ -1,21 +1,20 @@
|
|||
import { List, Record } from 'immutable';
|
||||
import createReducer from 'utils/createReducer';
|
||||
import * as actions from './actions';
|
||||
|
||||
const State = Record({
|
||||
const initialState = {
|
||||
show: false,
|
||||
results: List()
|
||||
});
|
||||
results: []
|
||||
};
|
||||
|
||||
export const getSearch = state => state.search;
|
||||
|
||||
export default createReducer(new State(), {
|
||||
[actions.socket.SEARCH](state, action) {
|
||||
return state.set('results', List(action.results));
|
||||
export default createReducer(initialState, {
|
||||
[actions.socket.SEARCH](state, { results }) {
|
||||
state.results = results;
|
||||
},
|
||||
|
||||
[actions.TOGGLE_SEARCH](state) {
|
||||
return state.set('show', !state.show);
|
||||
state.show = !state.show;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue