Example in JavaScript

The following is an example of a stubSpeakerReducer in JavaScript. You'll note that regardless of the action passed in, a new UNABLE_TO_RETRIEVE_SPEAKERS error is pushed to the error array in the state.

 import { SpeakerErrors } from './errors';
import { SpeakerFilters } from './actions';

const initialState = {
speakerFilter: SpeakerActions.SHOW_ALL,
speakers: [],
errors: []
};

export function stubSpeakerReducer(state, action) {
state = state || initialState;

state.speakerFilter = action.filter || SpeakerFilters.SHOW_ALL;
state.errors.push(SpeakerErrors.UNABLE_TO_RETRIEVE_SPEAKERS);

return state;
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.26.22