Created
November 10, 2019 14:47
-
-
Save CharGrnmn/a047e589b09bdcfa27a375f13c8ef668 to your computer and use it in GitHub Desktop.
switchMap Example
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
| @Effect() | |
| findAddresses: Observable<any> = this.actions.pipe( | |
| ofType(LocationActionTypes.FindAddresses), | |
| map(action => action.partialAddress), | |
| debounceTime(400), | |
| distinctUntilChanged(), | |
| switchMap(partialAddress => this.backend | |
| .findAddresses(partialAddress) | |
| .pipe( | |
| map(results => new FindAddressesFulfilled(results)), | |
| catchError(error => of(new FindAddressesRejected(error))) | |
| ) | |
| ) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment