Skip to content

Instantly share code, notes, and snippets.

@dpalita
Last active August 2, 2018 20:18
Show Gist options
  • Save dpalita/d38e576d871673feb17469ba18b15948 to your computer and use it in GitHub Desktop.
Save dpalita/d38e576d871673feb17469ba18b15948 to your computer and use it in GitHub Desktop.
Store ngrx initial state read via a promise in indexedDb
@Injectable()
export class AccountReducer {
private initialState: AccountState
...
bootstrap(): Promise<AccountState> {
return new Promise(resolve =>
// rehydrate uses indexedDb to read the state
this.rehydrate(this.storage).subscribe(initialState => {
this.initialState = initialState
resolve()
})
)
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment