Skip to content

Instantly share code, notes, and snippets.

@Tecayehuatl
Created May 25, 2020 04:33
Show Gist options
  • Save Tecayehuatl/66b5b150531f5247acdfa00b53db844e to your computer and use it in GitHub Desktop.
Save Tecayehuatl/66b5b150531f5247acdfa00b53db844e to your computer and use it in GitHub Desktop.
import { createReducer, on, Action } from '@ngrx/store';
import { initialAppState, IApp } from '../app.interface';
import { login, loginSuccess, loginFail } from '../actions/app.actions';
export const userFeatureKey = 'AppState';
export const reducer = createReducer(
initialAppState as IApp,
on(login, (state) => ({
...state,
})),
on(loginSuccess, (state) => ({
...state,
authenticationMessage: null,
})),
on(loginFail, (state, { message }) => ({
...state,
authenticationMessage: message,
}))
);
export function AppReducer(state: IApp, action: Action): IApp {
return reducer(state as IApp, action as Action);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment