Skip to content

Instantly share code, notes, and snippets.

@CharGrnmn
Created November 10, 2019 14:47
Show Gist options
  • Select an option

  • Save CharGrnmn/a047e589b09bdcfa27a375f13c8ef668 to your computer and use it in GitHub Desktop.

Select an option

Save CharGrnmn/a047e589b09bdcfa27a375f13c8ef668 to your computer and use it in GitHub Desktop.
switchMap Example
@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