angular - How to use exhaustMap in ReactiveX/rxjs 5 in TypeScript -


i wondering how can process array each value returns promise in same order they're specified. example, let's want call multiple ajax calls in order:

var array = [     'http://example.org',     'http://otherexample.org',     'http://anotherexample.org', ]; 

there's basicaly same question: how can use rxjs hold off requests ajax call until previous 1 resolves, suggests using flatmapfirst.

since i'm using angular2 (beta-15 @ moment) in typescript uses rxjs@5.0.0-beta.2 found out flatmapfirst has been renamed exhaustmap.

but operator isn't listed in observable.ts, therefore can't use it. it's not present in bundled version of rxjs https://code.angularjs.org/2.0.0-beta.15/rx.js.

so, how supposed use it? or there other way need? package.json lists lot of build scripts, should force use 1 of them?

edit: should mention i'm using reactivex/rxjs library, not reactive-extensions/rxjs

operator concatmap() did job:

import { observable } 'rxjs/observable'; import 'rxjs/add/operator/concatmap';  var urls = [   'https://httpbin.org/get?1',   'https://httpbin.org/get?2',   'https://httpbin.org/get?3',   'https://httpbin.org/get?4',   'https://httpbin.org/get?5', ];       observable.from(this.urls)   .concatmap(url => http.get(url))   .subscribe(response => console.log(response.url)) ; 

this prints console:

https://httpbin.org/get?1 https://httpbin.org/get?2 https://httpbin.org/get?3 https://httpbin.org/get?4 https://httpbin.org/get?5 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -