Skip to content
Snippets Groups Projects
Commit a4579e54 authored by Art Lowel's avatar Art Lowel
Browse files

Added a configuration parameter to enable/disable the rehydrate step

parent 57c20d61
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,10 @@ module.exports = {
},
"cache": {
// how long should objects be cached for by default
"msToLive": 15 * 60 * 1000 //15 minutes
"msToLive": 15 * 60 * 1000, //15 minutes
},
"universal": {
//on the client: start with the state on the server
"shouldRehydrate": true
}
};
......@@ -22,6 +22,7 @@ import { effects } from './app/app.effects';
// see https://github.com/angular/angular/pull/12322
import { Meta } from './angular2-meta';
import { RehydrateStoreAction } from "./app/store.actions";
import { GlobalConfig } from "./config";
// import * as LRU from 'modern-lru';
......@@ -91,9 +92,11 @@ export class MainModule {
}
doRehydrate() {
let defaultValue = {};
let serverCache = this._getCacheValue(NGRX_CACHE_KEY, defaultValue);
this.store.dispatch(new RehydrateStoreAction(serverCache));
if (GlobalConfig.universal.shouldRehydrate) {
let defaultValue = {};
let serverCache = this._getCacheValue(NGRX_CACHE_KEY, defaultValue);
this.store.dispatch(new RehydrateStoreAction(serverCache));
}
}
_getCacheValue(key: string, defaultValue: any): any {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment