Skip to content

Instantly share code, notes, and snippets.

@trinhvanhuy
Created January 15, 2019 12:33
Show Gist options
  • Save trinhvanhuy/9ebf77d2ef12aba244e595805939a174 to your computer and use it in GitHub Desktop.
Save trinhvanhuy/9ebf77d2ef12aba244e595805939a174 to your computer and use it in GitHub Desktop.
Spinner - State & selector
import {
ActionReducerMap,
createSelector,
createFeatureSelector,
ActionReducer,
MetaReducer,
} from '@ngrx/store';
import { environment } from '@environments/environment';
import { storeFreeze } from 'ngrx-store-freeze';
import * as fromGlobal from '@reducers/gloabal.reducer';
export interface AppState {
global: fromGlobal.State;
}
export const reducers: ActionReducerMap<AppState> = {
user: fromUser.reducer,
global: fromGlobal.reducer
};
// console.log all actions
export function logger(reducer: ActionReducer<AppState>): ActionReducer<AppState> {
return function (state: AppState, action: any): AppState {
return reducer(state, action);
};
}
export const metaReducers: MetaReducer<AppState>[] = !environment.production
? [logger, storeFreeze]
: [];
// GLOBAL REDUCER
export const getSpinnerCounter = createSelector(getGlobalState, fromGlobal.getSpinnerCounter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment