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

Commit fbf6bbd

Browse files
committed
Changed signature of scan from (initial: A, accumulator: (A, A)=>A) to (initial: => A)(accumulator: (A,A) => A)
Removed scanWith as the supplier version can be covered by the signature change of scan above. Furthermore, the scan operator is actually using scanWith operator on reactor-core. Signed-off-by: Winarto Zhao <[email protected]>
1 parent fe49484 commit fbf6bbd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ trait SFlux[T] extends SFluxLike[T, SFlux] with MapablePublisher[T] with ScalaCo
581581

582582
final def scan(accumulator: (T, T) => T): SFlux[T] = coreFlux.scan(accumulator).asScala
583583

584-
final def scan[A >: T](initial: A, accumulator: (A, A) => A): SFlux[A] = coreFlux.scan(initial, accumulator).asScala
584+
final def scan[A >: T](initial: => A)(accumulator: (A, A) => A): SFlux[A] = coreFlux.scanWith(() => initial, accumulator).asScala
585585

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

588588
final def single(defaultValue: Option[T] = None): SMono[T] = {
589589
(defaultValue map { coreFlux.single(_) } getOrElse {coreFlux.single()}).asScala

src/test/scala/reactor/core/scala/publisher/SFluxTest.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,25 +1805,27 @@ class SFluxTest extends AnyFreeSpec with Matchers with TableDrivenPropertyChecks
18051805
.verifyComplete()
18061806
}
18071807
"with initial value should scan with provided initial value" in {
1808-
val flux = SFlux.just(1, 2, 3, 4).scan(2, { (a: Int, b: Int) => a * b })
1808+
val flux = SFlux.just(1, 2, 3, 4).scan(2){ (a: Int, b: Int) => a * b }
18091809
StepVerifier.create(flux)
18101810
.expectNext(2, 2, 4, 12, 48)
18111811
.verifyComplete()
18121812
}
18131813

18141814
"with initial value should be able to call scan without the generic type" in {
1815-
val flux = SFlux.just("item1", "item2").scan("prefix", {(a, b) => a+b})
1815+
val flux = SFlux.just("item1", "item2").scan("prefix"){(a, b) => a+b}
18161816
StepVerifier.create(flux)
18171817
.expectNext("prefix", "prefixitem1", "prefixitem1item2")
18181818
.verifyComplete()
18191819
}
18201820
}
18211821

1822+
/*
18221823
".scanWith should scan with initial value" in {
18231824
StepVerifier.create(SFlux.just(1, 2, 3, 4).scanWith(() => 2, { (a, b) => a * b }))
18241825
.expectNext(2, 2, 4, 12, 48)
18251826
.verifyComplete()
18261827
}
1828+
*/
18271829

18281830
".single" - {
18291831
"should return a mono" in {

0 commit comments

Comments
 (0)