Created
January 15, 2019 12:33
-
-
Save trinhvanhuy/9ebf77d2ef12aba244e595805939a174 to your computer and use it in GitHub Desktop.
Spinner - State & selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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