Skip to content

Commit

Permalink
updating how we call cache func
Browse files Browse the repository at this point in the history
  • Loading branch information
chazeah committed Mar 8, 2017
1 parent eeb0b23 commit 57785b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src-frontend/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { AssociateEmailModule } from './associate-email/associate-email.module'
import { AuthModule } from './auth-github/auth.module';
import { INITIAL_DATA_CACHE } from './initial-data-cache';
import { INITIAL_DATA_CACHE, loadInitialDataCache } from './initial-data-cache';
import { PageNotFoundComponent } from './not-found.component';
import { RepositoryModule } from './repository/repository.module';

Expand All @@ -29,13 +29,14 @@ import { RepositoryModule } from './repository/repository.module';
],
providers: [
{
// Ensure CSRF tokens are included in headers during API requests.
provide: XSRFStrategy,
useValue: new CookieXSRFStrategy('csrftoken', 'X-CSRFToken'),
},
{
provide: INITIAL_DATA_CACHE,
// Inject serverside data if we got it.
useFactory: () => window['ME_DATA']
provide: INITIAL_DATA_CACHE,
useFactory: loadInitialDataCache
},
],
entryComponents: [
Expand Down
4 changes: 4 additions & 0 deletions src-frontend/app/initial-data-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { OpaqueToken } from '@angular/core';
// Enables us to dynmically inject serverside data to hydrate our views immediately.
// https://angular.io/docs/ts/latest/guide/dependency-injection.html
export let INITIAL_DATA_CACHE = new OpaqueToken('INITIAL_DATA_CACHE');

export function loadInitialDataCache() {
return window['ME_DATA'];
}

0 comments on commit 57785b1

Please sign in to comment.