Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wesleygrimes/ff9cc03e43a46aae360f1c872d757193 to your computer and use it in GitHub Desktop.
Save wesleygrimes/ff9cc03e43a46aae360f1c872d757193 to your computer and use it in GitHub Desktop.
Standard Feature Store Module - Reducer
import { Actions, ActionTypes } from './actions';
import { initialState, State } from './state';
export function featureReducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionTypes.LOGIN_REQUEST:
return {
...state,
error: null,
isLoading: true
};
case ActionTypes.LOGIN_SUCCESS:
return {
...state,
user: action.payload.user,
error: null,
isLoading: false,
};
case ActionTypes.LOGIN_FAILURE:
return {
...state,
error: action.payload.error,
isLoading: false
};
default: {
return state;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment