const Immutable = require('immutable'); import * as ScorebarActions from '../../actions/board/scorebar.actions'; import ScorebarCtrl from '../../controllers/scorebar.controller.js'; const initial = { current: ScorebarCtrl.getCurrentScore(), high: ScorebarCtrl.getHighScore(), lives: ScorebarCtrl.getLives() }; const reducer = (state = initial, action) => { if (action.type !== ScorebarActions.SCOREBAR_ACTION) { return state; } return Immutable.Map(state) .set('current', ScorebarCtrl.getCurrentScore()) .set('high', ScorebarCtrl.getHighScore()) .set('lives', ScorebarCtrl.getLives()) .toObject(); }; export default reducer;