Last active
August 2, 2018 20:17
-
-
Save dpalita/60a10d7b27fa0899c2fd6de660a4d9c4 to your computer and use it in GitHub Desktop.
Store ngrx initial state read via a promise in indexedDb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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