Skip to content

Instantly share code, notes, and snippets.

@yinonov
Created February 11, 2019 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yinonov/3ff154e7b3e1e7e37e280af52aa5682d to your computer and use it in GitHub Desktop.
Save yinonov/3ff154e7b3e1e7e37e280af52aa5682d to your computer and use it in GitHub Desktop.
code example for preserving cart state article
onLoad$ = this.auth.user$.pipe(
take(1), // we only do this once as we only want to handle the initial load
switchMap(user => !!user ? mergedCartStates$ : cartStateFromStorage$),
// set the cart form with the retrieved state's value
tap(setCartValue) // set the cart's form with emitted value
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment