1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
### `Rx.Observable.prototype.concatMapObserver(onNext, onError, onCompleted, [thisArg])`
### `Rx.Observable.prototype.selectConcatObserver(onNext, onError, onCompleted, [thisArg])`
[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/concatmapobserver.js "View in source")
Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.
#### Arguments
1. `onNext` *(`Function`)*: A transform function to apply to each element. The selector is called with the following information:
1. the value of the element
2. the index of the element
2. `onError` *(`Function`)*: A transform function to apply when an error occurs in the source sequence.
3. `onCompleted` *(`Function`)*: A transform function to apply when the end of the source sequence is reached.
4. `[thisArg]` *(`Any`)*: Object to use as `this` when executing the transform functions.
#### Returns
*(`Observable`)*: An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
#### Example
```js
var source = Rx.Observable.range(1, 3)
.concatMapObserver(
function (x, i) {
return Rx.Observable.repeat(x, i);
},
function (err) {
return Rx.Observable.return(42);
},
function () {
return Rx.Observable.empty();
});
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: 2
// => Next: 3
// => Next: 3
// => Completed
```
### Location
File:
- [`/src/core/linq/observable/concatmapobserver.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/concatmapobserver.js)
Dist:
- [`rx.all.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.all.js)
- [`rx.all.compat.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.all.compat.js)
- [`rx.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.js)
- [`rx.compat.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.compat.js)
NPM Packages:
- [`rx`](https://www.npmjs.org/package/rx)
NuGet Packages:
- [`RxJS-All`](http://www.nuget.org/packages/RxJS-All/)
- [`RxJS-Main`](http://www.nuget.org/packages/RxJS-Main/)
Unit Tests:
- [`/tests/observable/concatmapobserver.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/concatmapobserver.js)
|