Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit 19190c3

Browse files
committed
Added scaladoc for SFlux.scan
1 parent 3ec5e3d commit 19190c3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/main/scala/reactor/core/scala/publisher/SFlux.scala

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,52 @@ trait SFlux[T] extends SFluxLike[T, SFlux] with MapablePublisher[T] with ScalaCo
698698
*/
699699
final def sampleFirst(timespan: Duration): SFlux[T] = coreFlux.sampleFirst(timespan).asScala
700700

701+
/**
702+
* Reduce this [[SFlux]] values with an accumulator [[Function2]] and
703+
* also emit the intermediate results of this function.
704+
* <p>
705+
* Unlike [[SFlux.scan(Anyref, Function2)]], this operator doesn't take an initial value
706+
* but treats the first [[SFlux]] value as initial value.
707+
* <br>
708+
* The accumulation works as follows:
709+
* <pre><code>
710+
* result[0] = source[0]
711+
* result[1] = accumulator(result[0], source[1])
712+
* result[2] = accumulator(result[1], source[2])
713+
* result[3] = accumulator(result[2], source[3])
714+
* ...
715+
* </code></pre>
716+
*
717+
* <p>
718+
* <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/master/reactor-core/src/main/java/reactor/core/publisher/doc-files/marbles/scanWithSameReturnType.svg" alt="">
719+
*
720+
* @param accumulator the accumulating [[Function2]]
721+
* @return an accumulating [[SFlux]]
722+
*/
701723
final def scan(accumulator: (T, T) => T): SFlux[T] = coreFlux.scan(accumulator).asScala
702724

725+
/**
726+
* Reduce this [[SFlux]] values with an accumulator [[Function2]] and
727+
* also emit the intermediate results of this function.
728+
* <p>
729+
* The accumulation works as follows:
730+
* <pre><code>
731+
* result[0] = initialValue;
732+
* result[1] = accumulator(result[0], source[0])
733+
* result[2] = accumulator(result[1], source[1])
734+
* result[3] = accumulator(result[2], source[2])
735+
* ...
736+
* </code></pre>
737+
*
738+
* <p>
739+
* <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/master/reactor-core/src/main/java/reactor/core/publisher/doc-files/marbles/scan.svg" alt="">
740+
*
741+
* @param initial the initial leftmost argument to pass to the reduce function
742+
* @param accumulator the accumulating [[Function2]]
743+
* @param < A> the accumulated type
744+
* @return an accumulating [[SFlux]] starting with initial state
745+
*
746+
*/
703747
final def scan[A >: T](initial: => A)(accumulator: (A, A) => A): SFlux[A] = coreFlux.scanWith(() => initial, accumulator).asScala
704748

705749
// final def scanWith[A >: T](initial: () => A, accumulator: (A, T) => A): SFlux[A] = coreFlux.scanWith(initial, accumulator).asScala

0 commit comments

Comments
 (0)