> For the complete documentation index, see [llms.txt](https://soufatn.gitbook.io/rxjs-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soufatn.gitbook.io/rxjs-book/summary/observable/observable_instance_methods/flatmapobserver.md).

# flatMapObserver | selectManyObserver

Projects each notification of an observable sequence to an observable sequence and merges 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

```javascript
var source = Rx.Observable.range(1, 3)
    .flatMapObserver(
        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
```
