Skip to content

Instantly share code, notes, and snippets.

@aliyeysides
Last active January 5, 2024 06:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliyeysides/efca74ec7d428219360cf5ea9fee1cbf to your computer and use it in GitHub Desktop.
Save aliyeysides/efca74ec7d428219360cf5ea9fee1cbf to your computer and use it in GitHub Desktop.
example use of .switchMap that streams value to multiple inner observables using static .combineLatest method
this.symbolSearchService.getSymbolData('xl')
.switchMap(stock => {
this.stock = stock;
return Observable.combineLatest(
this.symbolSearchService.getResearchReportData(stock),
this.symbolSearchService.getPGRDataAndContextSummary(stock)
)})
.subscribe(
[report, summary] => {
this.researchReport = report;
this.contextSummary = summary;
},
err => this.sharedService.handleError
);
@mazolo
Copy link

mazolo commented Jul 18, 2019

I came across this very useful piece of code that I needed most. This helped me wrap my head around rxjs operators. Big up to you man.

@eafiontzi
Copy link

helped me a lot as well!! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment