You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
837 B
32 lines
837 B
const Immutable = require('immutable');
|
|
|
|
import * as TroggleActions from '../../actions/board/troggle.actions';
|
|
|
|
const initial = [];
|
|
|
|
const reducer = (state = initial, action) => {
|
|
if (action.type !== TroggleActions.TROGGLE_ACTION) {
|
|
return state;
|
|
}
|
|
|
|
switch (action.action) {
|
|
case TroggleActions.UPDATE:
|
|
return Immutable.fromJS(state)
|
|
.setIn([action.index, 'x'], action.x)
|
|
.setIn([action.index, 'y'], action.y)
|
|
.toJS();
|
|
|
|
case TroggleActions.CREATE:
|
|
return Immutable.List(state)
|
|
.set(action.index, { x: action.x, y: action.y })
|
|
.toArray();
|
|
|
|
case TroggleActions.CLEAR_ALL:
|
|
return Immutable.List()
|
|
.toArray();
|
|
};
|
|
|
|
return state;
|
|
};
|
|
|
|
export default reducer;
|
|
|