I have multiple observables that emit values during the lifetime of the page. For example:
chartData$: Observable;
tableData$: Observable;
filterData$: Observable;
At any time user can click the 'Download' button, and get the JSON combining the values that were last emitted from each of these observables:
downloadButtonClicked$.pipe(
combine chartData$, tableData$ and filterData$ // <- how do I get latest values here?
).subscribe(([chart, table, filter]) => downloadJson(chart, table, filter))
but the downloadJson function shouldn't be called when any of these 3 observables emit values as part of page lifecycle, only on Download click.
TLDR;
working most elegant solution (as suggested by Mike) https://stackblitz.com/edit/typescript-jm3zma?file=index.ts