Skip to content

Commit

Permalink
fix scala 3 build for collection factory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman committed Jun 22, 2024
1 parent 8ac6997 commit 298413a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions colibri/src/main/scala/colibri/Observable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1316,11 +1316,13 @@ object Observable {
}
}

@inline def bufferTimed[Col[_]](duration: FiniteDuration)(implicit factory: Factory[A, Col[A]]): Observable[Col[A]] = bufferTimedMillis(
@inline def bufferTimed[Col[a] <: Iterable[a]](duration: FiniteDuration)(implicit factory: Factory[A, Col[A]]): Observable[Col[A]] =
bufferTimedMillis(
duration.toMillis.toInt,
)

def bufferTimedMillis[Col[_]](duration: Int)(implicit factory: Factory[A, Col[A]]): Observable[Col[A]] = new Observable[Col[A]] {
def bufferTimedMillis[Col[a] <: Iterable[a]](duration: Int)(implicit factory: Factory[A, Col[A]]): Observable[Col[A]] =
new Observable[Col[A]] {
def unsafeSubscribe(sink: Observer[Col[A]]): Cancelable = {
var isCancel = false
var builder = factory.newBuilder
Expand Down Expand Up @@ -1470,13 +1472,14 @@ object Observable {
def foldIO[B](seed: B)(f: (B, A) => B): IO[B] = scan(seed)(f).lastIO
def unsafeFoldFuture[B](seed: B)(f: (B, A) => B): Future[B] = scan(seed)(f).unsafeLastFuture()

def foldAllF[F[_]: Async, Col[_]](implicit factory: Factory[A, Col[A]]): F[Col[A]] = foldF(factory.newBuilder) { (buff, next) =>
def foldAllF[F[_]: Async, Col[a] <: Iterable[a]](implicit factory: Factory[A, Col[A]]): F[Col[A]] = foldF(factory.newBuilder) {
(buff, next) =>
buff += next
buff
}.map(_.result())
def foldAllIO[Col[_]](implicit factory: Factory[A, Col[A]]): IO[Col[A]] = foldAllF[IO, Col]
def foldAll[Col[_]](implicit factory: Factory[A, Col[A]]): Observable[Col[A]] = Observable.fromEffect(foldAllIO[Col])
def unsafeFoldToFuture[Col[_]]()(implicit factory: Factory[A, Col[A]]): Future[Col[A]] =
def foldAllIO[Col[a] <: Iterable[a]](implicit factory: Factory[A, Col[A]]): IO[Col[A]] = foldAllF[IO, Col]
def foldAll[Col[a] <: Iterable[a]](implicit factory: Factory[A, Col[A]]): Observable[Col[A]] = Observable.fromEffect(foldAllIO[Col])
def unsafeFoldToFuture[Col[a] <: Iterable[a]]()(implicit factory: Factory[A, Col[A]]): Future[Col[A]] =
foldAllIO[Col].unsafeToFuture()(cats.effect.unsafe.IORuntime.global)

@inline def prependEffect[F[_]: RunEffect](value: F[A]): Observable[A] = concatEffect[F, A](value, source)
Expand Down

0 comments on commit 298413a

Please sign in to comment.