Last active
November 9, 2018 07:47
-
-
Save Mulperi/c83864d29e60b2bd5eee887d097b5fa1 to your computer and use it in GitHub Desktop.
NGRX Effect and withLatestFrom example
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
@Effect() | |
selectItem$ = this.actions$.pipe( | |
ofType(itemAction.ITEM_SELECT), | |
concatMap(() => | |
this.store.select(fromItems.getItemsSelected) | |
), | |
withLatestFrom( | |
this.store.select(fromUi.getItemsSideviewVisible) | |
), | |
filter( | |
// Do not dispatch new action if sideview is already visible | |
([selected, sideViewVisible]) => | |
!sideViewVisible && selected.length > 0 | |
), | |
map(() => new uiAction.ShowItemsSideview()) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment