[RxJS] Use RxJS mergeMap to map and merge high order observables
2016-12-19 21:43
330 查看
Like RxJS switchMap() is a shortcut for map() and switch(), we will see in this lesson how mergeMap() is a shortcut for map() and mergeAll(), and learn its arguments for customised behavior.
const clickObservable = Rx.Observable .fromEvent(document, 'click'); function performRequest() { return fetch('https://jsonplaceholder.typicode.com/users/1') .then(res => res.json()); } const emailObservable = clickObservable .mergeMap(click => performRequest(), (click, res) => res.email, // selector function 3); // number of concurrency // mergeMap = map ... + ... mergeAll emailObservable .subscribe(email => console.log(email));
相关文章推荐
- [RxJS] Use RxJS concatMap to map and concat high order observables
- Use data define file and colmap to map different column
- Use gitk to understand git – merge and rebase
- [RxJS] Use takeUntil instead of manually unsubscribing from Observables
- [Redux-Observable && Unit Testing] Use tests to verify updates to the Redux store (rxjs scheduler)
- Why I can't use non-string key in the myMap[myKey] expression? And what to do now?
- Use gitk to understand git – merge and rebase
- [Nuxt] Use Vuex Actions to Delete Data from APIs in Nuxt and Vue.js
- [Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose
- How to use $http and $resource in Angular JS
- [RxJS] Conclusion: when to use Subjects
- Use DropzondJS and Spring to upload and download file
- [RxJS] Learn How To Use RxJS 5.5 Beta 2
- Internet Information Services is not installed. You must have Internet Information Services installed in order to use the SharePoint Products and Technologies Configuration Wizard
- Why we made vorlon.js and how to use it to debug your JavaScript remotely
- [rxjs] Demystifying Cold and Hot Observables in RxJS
- jsbin-jsfiddle-or-codepen-which-one-to-use-and-why
- Use mail merge to create custom letters, invoices, labels and more
- [RxJS] Convert RxJS Subjects to Observables
- [RxJS] Flatten a higher order observable with mergeAll in RxJS