Packages

  • package root
    Definition Classes
    root
  • package fs2
    Definition Classes
    root
  • package interop
    Definition Classes
    fs2
  • package flow

    Implementation of the reactive-streams protocol for fs2; based on Java Flow.

    Implementation of the reactive-streams protocol for fs2; based on Java Flow.

    Definition Classes
    interop
    Deprecated

    All syntax has been moved directly onto Stream.

    Example:
    1. scala> import cats.effect.IO
      scala> import fs2.Stream
      scala> import java.util.concurrent.Flow.Publisher
      scala>
      scala> val upstream: Stream[IO, Int] = Stream(1, 2, 3).covary[IO]
      scala> val publisher: Stream[IO, Publisher[Int]] = upstream.toPublisher
      scala> val downstream: Stream[IO, Int] = publisher.flatMap { publisher =>
           |   Stream.fromPublisher[IO](publisher, chunkSize = 16)
           | }
      scala>
      scala> import cats.effect.unsafe.implicits.global
      scala> downstream.compile.toVector.unsafeRunSync()
      res0: Vector[Int] = Vector(1, 2, 3)
    See also

    java.util.concurrent.Flow

  • package reactivestreams

    Implementation of the reactivestreams protocol for fs2

    Implementation of the reactivestreams protocol for fs2

    Definition Classes
    interop
    Deprecated

    The next major version of fs2 will drop these converters. Rather, users will be encouraged to use the new fs2.interop.flow package, which provides support for the java.util.concurrent.Flow types; that superseded the reactive-streams library. In case you need to interop with a library that only provides reactive-streams types, you may use org.reactivestreams.FlowAdapters

    Example:
    1. scala> import fs2._
      scala> import fs2.interop.reactivestreams._
      scala> import cats.effect.{IO, Resource}, cats.effect.unsafe.implicits.global
      scala>
      scala> val upstream: Stream[IO, Int] = Stream(1, 2, 3).covary[IO]
      scala> val publisher: Resource[IO, StreamUnicastPublisher[IO, Int]] = upstream.toUnicastPublisher
      scala> val downstream: Stream[IO, Int] = Stream.resource(publisher).flatMap(_.toStreamBuffered[IO](bufferSize = 16))
      scala>
      scala> downstream.compile.toVector.unsafeRunSync()
      res0: Vector[Int] = Vector(1, 2, 3)
    See also

    http://www.reactive-streams.org/

  • PublisherOps
  • StreamOps
  • StreamSubscriber
  • StreamUnicastPublisher
  • package scodec
    Definition Classes
    interop
p

fs2.interop

reactivestreams

package reactivestreams

Implementation of the reactivestreams protocol for fs2

Deprecated

The next major version of fs2 will drop these converters. Rather, users will be encouraged to use the new fs2.interop.flow package, which provides support for the java.util.concurrent.Flow types; that superseded the reactive-streams library. In case you need to interop with a library that only provides reactive-streams types, you may use org.reactivestreams.FlowAdapters

Source
package.scala
Example:
  1. scala> import fs2._
    scala> import fs2.interop.reactivestreams._
    scala> import cats.effect.{IO, Resource}, cats.effect.unsafe.implicits.global
    scala>
    scala> val upstream: Stream[IO, Int] = Stream(1, 2, 3).covary[IO]
    scala> val publisher: Resource[IO, StreamUnicastPublisher[IO, Int]] = upstream.toUnicastPublisher
    scala> val downstream: Stream[IO, Int] = Stream.resource(publisher).flatMap(_.toStreamBuffered[IO](bufferSize = 16))
    scala>
    scala> downstream.compile.toVector.unsafeRunSync()
    res0: Vector[Int] = Vector(1, 2, 3)
See also

http://www.reactive-streams.org/

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. reactivestreams
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. implicit final class PublisherOps[A] extends AnyVal
  2. implicit final class StreamOps[F[_], A] extends AnyRef
  3. final class StreamSubscriber[F[_], A] extends Subscriber[A]

    Implementation of a org.reactivestreams.Subscriber.

    Implementation of a org.reactivestreams.Subscriber.

    This is used to obtain a fs2.Stream from an upstream reactivestreams system.

    See also

    https://github.com/reactive-streams/reactive-streams-jvm#2-subscriber-code

  4. final class StreamUnicastPublisher[F[_], A] extends Publisher[A]

    Implementation of a org.reactivestreams.Publisher

    Implementation of a org.reactivestreams.Publisher

    This is used to publish elements from a Stream to a downstream reactive-streams system.

    Note

    Not longer unicast, this Publisher can be reused for multiple Subscribers: each subscription will re-run the Stream from the beginning. However, a _parallel_ Dispatcher is required to allow concurrent subscriptions. Please, refer to the apply factory in the companion object that only requires a stream.

    See also

    https://github.com/reactive-streams/reactive-streams-jvm#1-publisher-code

Value Members

  1. def fromPublisher[F[_], A](p: Publisher[A], bufferSize: Int)(implicit arg0: Async[F]): Stream[F, A]

    Creates a lazy stream from an org.reactivestreams.Publisher.

    Creates a lazy stream from an org.reactivestreams.Publisher.

    The publisher only receives a subscriber when the stream is run.

    bufferSize

    setup the number of elements asked each time from the org.reactivestreams.Publisher. A high number can be useful if the publisher is triggering from IO, like requesting elements from a database. The publisher can use this bufferSize to query elements in batch. A high number will also lead to more elements in memory.

  2. def subscribeStream[F[_], A](stream: Stream[F, A], subscriber: Subscriber[A])(implicit F: Async[F]): F[Unit]

    Allows subscribing a org.reactivestreams.Subscriber to a Stream.

    Allows subscribing a org.reactivestreams.Subscriber to a Stream.

    The returned program will run until all the stream elements were consumed. Cancelling this program will gracefully shutdown the subscription.

    stream

    the Stream that will be consumed by the subscriber.

    subscriber

    the Subscriber that will receive the elements of the stream.

  3. object StreamSubscriber
  4. object StreamUnicastPublisher

Deprecated Value Members

  1. def fromPublisher[F[_], A](p: Publisher[A])(implicit arg0: Async[F]): Stream[F, A]

    Creates a lazy stream from an org.reactivestreams.Publisher.

    Creates a lazy stream from an org.reactivestreams.Publisher.

    The publisher only receives a subscriber when the stream is run.

    Annotations
    @deprecated
    Deprecated

    (Since version 3.1.4) Use fromPublisher method with a buffer size. Use a buffer size of 1 to keep the same behavior.

Inherited from AnyRef

Inherited from Any

Ungrouped