fixed rehydrate issue

This commit is contained in:
Art Lowel
2017-09-07 13:06:58 +02:00
parent 30ee3859c8
commit b66a70b526
4 changed files with 12 additions and 18 deletions

View File

@@ -1,8 +1,7 @@
import { isNotEmpty } from './shared/empty.util';
import { StoreActionTypes } from './store.actions';
// crude temporary ngrx debugger for use until
// https://github.com/ngrx/platform/issues/97 is fixed
// fallback ngrx debugger
let actionCounter = 0;
export function debugMetaReducer(reducer) {
@@ -26,12 +25,14 @@ export function universalMetaReducer(reducer) {
state = Object.assign({}, state, action.payload);
break;
case StoreActionTypes.REPLAY:
break;
default:
break;
}
return reducer(state, action);
}
}
}
export const appMetaReducers = [debugMetaReducer, universalMetaReducer];
export const appMetaReducers = [
// debugMetaReducer,
universalMetaReducer,
];

View File

@@ -46,7 +46,6 @@ export function HttpLoaderFactory(http: Http) {
}),
IdlePreloadModule.forRoot(), // forRoot ensures the providers are only created once
RouterModule.forRoot([], { useHash: false, preloadingStrategy: IdlePreload }),
StoreRouterConnectingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
@@ -60,6 +59,7 @@ export function HttpLoaderFactory(http: Http) {
BrowserTransferStateModule,
BrowserTransferStoreModule,
EffectsModule.forRoot([BrowserTransferStoreEffects]),
StoreRouterConnectingModule,
BrowserAnimationsModule,
AppModule
],

View File

@@ -1,8 +1,8 @@
import { Injectable, Inject } from '@angular/core';
import { Injectable } from '@angular/core';
import { Actions, Effect } from '@ngrx/effects';
import { ObjectCacheActionTypes } from '../cache/object-cache.actions';
import { ResetResponseCacheTimestampsAction } from '../cache/response-cache.actions';
import { StoreActionTypes } from '../../store.actions';
@Injectable()
export class RequestCacheEffects {
@@ -14,17 +14,9 @@ export class RequestCacheEffects {
*
* This assumes that the server cached everything a negligible
* time ago, and will likely need to be revisited later
*
* This effect should listen for StoreActionTypes.REHYDRATE,
* but can't because you can only have one effect listen to
* an action atm. Github issue:
* https://github.com/ngrx/effects/issues/87
*
* It's listening for ObjectCacheActionTypes.RESET_TIMESTAMPS
* instead, until there's a solution.
*/
@Effect() fixTimestampsOnRehydrate = this.actions$
.ofType(ObjectCacheActionTypes.RESET_TIMESTAMPS)
.ofType(StoreActionTypes.REHYDRATE)
.map(() => new ResetResponseCacheTimestampsAction(new Date().getTime()));
constructor(private actions$: Actions, ) { }

View File

@@ -8,6 +8,7 @@ import { StoreAction, StoreActionTypes } from '../../app/store.actions';
import { AppState } from '../../app/app.reducer';
import { GLOBAL_CONFIG, GlobalConfig } from '../../config';
import { RouterNavigationAction } from '@ngrx/router-store';
@Injectable()
export class BrowserTransferState extends TransferState {