## `Rx.Observable.prototype.flatMapWithMaxConcurrent(maxConcurrent, selector, [resultSelector], [thisArg])`, `Rx.Observable.prototype.selectWithMaxConcurrent(maxConcurrent, selector, [resultSelector], [thisArg])`

This is an alias for the `selectWithMaxConcurrent` method. This can be one of the following:

Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence with the given concurrency limit.

``````source.flatMapWithMaxConcurrent(10, function (x, i) { return Rx.Observable.range(0, x); });
source.flatMapWithMaxConcurrent(1, function (x, i) { return Promise.resolve(x + 1); });
source.flatMapWithMaxConcurrent(1, function (x, i) { return [x, i]; });
``````

Projects each element of an observable sequence or Promise to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence with the given concurrency limit.

``````source.flatMapWithMaxConcurrent(10, function (x, i) { return Rx.Observable.range(0, x); }, function (x, y, ix, iy) { return x + y + ix + iy; });
source.flatMapWithMaxConcurrent(1, function (x, i) { return Promise.resolve(x + i); }, function (x, y, ix, iy) { return x + y + ix + iy; });
source.flatMapWithMaxConcurrent(1, function (x, i) { return [x, i];  }, function (x, y, ix, iy) { return x + y + ix + iy; });
``````

Projects each element of the source observable sequence to the other observable sequence or Promise or array/iterable and merges the resulting observable sequences into one observable sequence with the given max concurrency limit.

``````source.flatMapWithMaxConcurrent(1, Rx.Observable.of(1,2,3));
source.flatMapWithMaxConcurrent(1, Promise.resolve(42));
source.flatMapWithMaxConcurrent(1, [1,2,3]);
``````

#### Arguments

1. `maxConcurrent` (`Number`): Maximum number of inner observable sequences being subscribed to concurrently.
2. `selector` (`Function` | `Iterable` | `Promise`): An Object to project to the sequence or a transform function to apply to each element or an observable sequence to project each element from the source sequence onto. The selector is called with the following information:

1. the value of the element
2. the index of the element
3. the Observable object being subscribed
3. `[resultSelector]` (`Function`): A transform function to apply to each element of the intermediate sequence. The resultSelector is called with the following information:

1. the value of the outer element
2. the value of the inner element
3. the index of the outer element
4. the index of the inner element
4. `[thisArg]` (`Any`): If `resultSelector` is not `Function`, Object to use as `this` when executing `selector`.

#### Returns

(`Observable`): An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.

#### Example

``````var source = Rx.Observable.range(0, 5)
.flatMapWithMaxConcurrent(2, function (x, i) {
return Rx.Observable
.interval(100)
.take(x).map(function() { return i; });
});

var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: 1
// => Next: 2
// => Next: 3
// => Next: 2
// => Next: 3
// => Next: 4
// => Next: 3
// => Next: 4
// => Next: 4
// => Next: 4
// => Completed

/* Using a promise */
var source = Rx.Observable.of(1,2,3,4)
.flatMapWithMaxConcurrent(1, function (x, i) {
return Promise.resolve(x + i);
});

var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: 1
// => Next: 3
// => Next: 5
// => Next: 7
// => Completed

/* Using an array */
var source = Rx.Observable.of(1,2,3)
.flatMapWithMaxConcurrent(
1,
function (x, i) { return [x,i]; },
function (x, y, ix, iy) { return x + y + ix + iy; }
);

var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: 2
// => Next: 2
// => Next: 5
// => Next: 5
// => Next: 8
// => Next: 8
// => Completed
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.57165366,"math_prob":0.96758926,"size":4343,"snap":"2021-21-2021-25","text_gpt3_token_len":1110,"char_repetition_ratio":0.18829224,"word_repetition_ratio":0.47492164,"special_character_ratio":0.29035228,"punctuation_ratio":0.25371286,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9691484,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-10T22:36:09Z\",\"WARC-Record-ID\":\"<urn:uuid:d8f32dbd-1660-4b2f-b3fc-5cdff74cd8a4>\",\"Content-Length\":\"192770\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a8afe6ca-af49-46b3-82c1-d93654333211>\",\"WARC-Concurrent-To\":\"<urn:uuid:42bf178a-b3a8-4636-8adf-c233fc78b8c2>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"https://xgrommx.github.io/rx-book/content/observable/observable_instance_methods/flatmapwithmaxconcurrent.html\",\"WARC-Payload-Digest\":\"sha1:2RRBJ6RUDHO73MEQIJ3I4VXRVAIOD5LU\",\"WARC-Block-Digest\":\"sha1:SEGJRPYO24ISGRK5DIHC2GKSUC4VHLZT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243989749.3_warc_CC-MAIN-20210510204511-20210510234511-00405.warc.gz\"}"}