appReducer.js 872 Bytes
/**
 * # guideReducer.js
 *
 * The reducer for all the actions from the various log states
 */
'use strict';
/**
 * ## Imports
 *
 * InitialState
 */
import InitialState from './appInitialState';

const {
	SET_PLATFORM,
	SET_CONTAINER,
	SET_CHANNEL,
} = require('../../constants/actionTypes').default;

const initialState = new InitialState;

/**
 * ## guideReducer function
 * @param {Object} state - initialState
 * @param {Object} action - type and payload
 */
export default function appReducer(state = initialState, action) {
    if (!(state instanceof InitialState)) return initialState.merge(state);

    switch (action.type) {
		case SET_PLATFORM:
			return state.set('platform', action.payload);
		case SET_CONTAINER:
			return state.set('container', action.payload);
		case SET_CHANNEL:
			return state.set('channel', action.payload);
    }

    return state;
}