How to use exitMap in ReactiveX / rxjs 5 in TypeScript

I was wondering how I can process an array, where each value returns Promise in the same order in which they are indicated. For example, let's say I want to call several Ajax calls in the following order:

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

Basically the same question: How to use RxJs to hold any AJAX call requests until the previous one resolves what the usage implies flatMapFirst.

Since I use Angular2 ( beta-15at the moment) in TypeScript, which uses rxjs@5.0.0-beta.2, I found that it was renamed to . flatMapFirstexhaustMap

But this operator is not specified in Observable.ts , so I can not use it. It is not even present in the combined version of RxJS https://code.angularjs.org/2.0.0-beta.15/Rx.js .

So how should I use it? Or is there some other way for what I need? Its package.json lists many build scripts, should I get it to use one of them?

Edit: I should mention that I am using ReactiveX / rxjs and not Reactive-Extensions / RxJS

+3
source share
1 answer

The operatorconcatMap() completed the task:

import { Observable } from '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))
;

:

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
+3

Source: https://habr.com/ru/post/1656409/


All Articles