Last active
August 2, 2018 20:18
-
-
Save dpalita/d38e576d871673feb17469ba18b15948 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