mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
fixed an issue where the reducers wouldn't be combined correctly when using AoT compilation
This commit is contained in:
@@ -11,7 +11,7 @@ import { StoreModule } from "@ngrx/store";
|
|||||||
import { RouterStoreModule } from "@ngrx/router-store";
|
import { RouterStoreModule } from "@ngrx/router-store";
|
||||||
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
|
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
|
||||||
|
|
||||||
import { reducers } from './app.reducers';
|
import { rootReducer } from './app.reducers';
|
||||||
import { effects } from './app.effects';
|
import { effects } from './app.effects';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -30,7 +30,7 @@ import { effects } from './app.effects';
|
|||||||
* meta-reducer. This returns all providers for an @ngrx/store
|
* meta-reducer. This returns all providers for an @ngrx/store
|
||||||
* based application.
|
* based application.
|
||||||
*/
|
*/
|
||||||
StoreModule.provideStore(reducers),
|
StoreModule.provideStore(rootReducer),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngrx/router-store keeps router state up-to-date in the store and uses
|
* @ngrx/router-store keeps router state up-to-date in the store and uses
|
||||||
|
@@ -1,7 +1,20 @@
|
|||||||
import { headerReducer } from './header/header.reducer';
|
import { combineReducers } from "@ngrx/store";
|
||||||
import { hostWindowReducer } from "./shared/host-window.reducer";
|
import { routerReducer, RouterState } from "@ngrx/router-store";
|
||||||
|
import { headerReducer, HeaderState } from './header/header.reducer';
|
||||||
|
import { hostWindowReducer, HostWindowState } from "./shared/host-window.reducer";
|
||||||
|
|
||||||
|
export interface AppState {
|
||||||
|
router: RouterState;
|
||||||
|
hostWindow: HostWindowState;
|
||||||
|
header: HeaderState;
|
||||||
|
}
|
||||||
|
|
||||||
export const reducers = {
|
export const reducers = {
|
||||||
headerReducer,
|
router: routerReducer,
|
||||||
hostWindowReducer
|
hostWindow: hostWindowReducer,
|
||||||
|
header: headerReducer
|
||||||
|
};
|
||||||
|
|
||||||
|
export function rootReducer(state: any, action: any) {
|
||||||
|
return combineReducers(reducers)(state, action);
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,7 @@ export class HeaderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.isNavBarCollapsed = this.store.select('headerReducer')
|
this.isNavBarCollapsed = this.store.select('header')
|
||||||
//ensure that state is not null, can happen when using AoT compilation
|
|
||||||
.filter((state: HeaderState) => state !== null && state !== undefined)
|
|
||||||
//unwrap navCollapsed
|
//unwrap navCollapsed
|
||||||
.map(({ navCollapsed }: HeaderState) => navCollapsed);
|
.map(({ navCollapsed }: HeaderState) => navCollapsed);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user