Last active
February 11, 2019 09:38
-
-
Save yinonov/315cdc033d39f2ef651f767c686ce73b to your computer and use it in GitHub Desktop.
code example for preserving cart state article
This file contains 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
cartChange$ = this.cartForm.valueChanges.pipe( | |
skipUntil(this.onLoad$.pipe(last())), // wait until onLoad$ is done | |
withLatestFrom(this.auth.user$), | |
switchMap(([cart, user]) => !!user ? | |
saveCartToDb$(cart) : // switch to saving to database observable | |
saveCartToStorage$(cart)) // switch to saving to storage observable | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment