Skip to content

Commit

Permalink
docs(mergeScan): add parameter docs (ReactiveX#6188)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen authored Mar 29, 2021
1 parent 980f4d4 commit c41f65b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/internal/operators/mergeScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ import { mergeInternals } from './mergeInternals';
* <span class="informal">It's like {@link scan}, but the Observables returned
* by the accumulator are merged into the outer Observable.</span>
*
* The first parameter of the `mergeScan` is an `accumulator` function which is
* being called every time the source Observable emits a value. `mergeScan` will
* subscribe to the value returned by the `accumulator` function and will emit
* values to the subscriber emitted by inner Observable.
*
* The `accumulator` function is being called with three parameters passed to it:
* `acc`, `value` and `index`. The `acc` parameter is used as the state parameter
* whose value is initially set to the `seed` parameter (the second parameter
* passed to the `mergeScan` operator).
*
* `mergeScan` internally keeps the value of the `acc` parameter: as long as the
* source Observable emits without inner Observable emitting, the `acc` will be
* set to `seed`. The next time the inner Observable emits a value, `mergeScan`
* will internally remember it and it will be passed to the `accumulator`
* function as `acc` parameter the next time source emits.
*
* The `value` parameter of the `accumulator` function is the value emitted by the
* source Observable, while the `index` is a number which represent the order of the
* current emission by the source Observable. It starts with 0.
*
* The last parameter to the `mergeScan` is the `concurrent` value which defaults
* to Infinity. It represent the maximum number of inner Observable subscriptions
* at a time.
*
* ## Example
* Count the number of click events
* ```ts
Expand Down

0 comments on commit c41f65b

Please sign in to comment.