Last active
May 16, 2018 12:56
-
-
Save jhades/1571d2c01117c60891325e301fe5f75f to your computer and use it in GitHub Desktop.
Angular Ngrx DevTools - https://blog.angular-university.io/angular-ngrx-devtools
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
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
.... | |
StoreModule.forRoot(reducers, { metaReducers }), | |
!environment.production ? StoreDevtoolsModule.instrument() : [] | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { | |
} |
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
{ | |
type: 'ROUTER_NAVIGATION', | |
payload: { | |
routerState: { | |
url: '/courses', | |
params: {}, | |
queryParams: {} | |
}, | |
event: { | |
id: 1, | |
url: '/courses', | |
urlAfterRedirects: '/courses', | |
state: { | |
url: '/courses', | |
params: {}, | |
queryParams: {} | |
} | |
} | |
} | |
} | |
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
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
... | |
StoreModule.forRoot(reducers, { metaReducers }), | |
!environment.production ? StoreDevtoolsModule.instrument() : [], | |
StoreRouterConnectingModule.forRoot({stateKey:'router'}) | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { | |
} | |
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 {routerReducer} from '@ngrx/router-store'; | |
export interface AppState { | |
} | |
export const reducers: ActionReducerMap<AppState> = { | |
router: routerReducer | |
}; | |
... |
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 {storeFreeze} from 'ngrx-store-freeze'; | |
import {routerReducer} from '@ngrx/router-store'; | |
export interface AppState { | |
} | |
export const reducers: ActionReducerMap<AppState> = { | |
router: routerReducer | |
}; | |
export const metaReducers: MetaReducer<AppState>[] = | |
!environment.production ? [storeFreeze] : []; | |
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
export function authReducer(state = initialAuthState, | |
action: AuthActions): AuthState { | |
switch (action.type) { | |
case AuthActionTypes.LoginAction: | |
state.loggedIn = true; | |
state.user = action.payload.user; | |
return state; | |
... | |
default: | |
return state; | |
} | |
} |
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
export function authReducer(state = initialAuthState, | |
action: AuthActions): AuthState { | |
switch (action.type) { | |
case AuthActionTypes.LoginAction: | |
return { | |
loggedIn: true, | |
user: action.payload.user | |
}; | |
.... | |
default: | |
return state; | |
} | |
} |
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
export enum CourseActionTypes { | |
CourseRequested = '[View Course Page] Course Requested', | |
CourseLoaded = '[Courses API] Course Loaded', | |
AllCoursesRequested = '[Courses Home Page] All Courses Requested', | |
AllCoursesLoaded = '[Courses API] All Courses Loaded', | |
CourseSaved = '[Edit Course Dialog] Course Saved' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment