ZHub

sealed abstract class ZHub[-RA, -RB, +EA, +EB, -A, +B] extends Serializable

A ZHub[RA, RB, EA, EB, A, B] is an asynchronous message hub. Publishers can publish messages of type A to the hub and subscribers can subscribe to take messages of type B from the hub. Publishing messages can require an environment of type RA and fail with an error of type EA. Taking messages can require an environment of type RB and fail with an error of type EB.

Companion:
object
class Object
trait Matchable
class Any
ZHub[RA, RB, EA, EB, A, B]

Value members

Abstract methods

Waits for the hub to be shut down.

Waits for the hub to be shut down.

The maximum capacity of the hub.

The maximum capacity of the hub.

Checks whether the hub is shut down.

Checks whether the hub is shut down.

def publish(a: A): ZIO[RA, EA, Boolean]

Publishes a message to the hub, returning whether the message was published to the hub.

Publishes a message to the hub, returning whether the message was published to the hub.

def publishAll(as: Iterable[A]): ZIO[RA, EA, Boolean]

Publishes all of the specified messages to the hub, returning whether they were published to the hub.

Publishes all of the specified messages to the hub, returning whether they were published to the hub.

Shuts down the hub.

Shuts down the hub.

def size: UIO[Int]

The current number of messages in the hub.

The current number of messages in the hub.

def subscribe: ZManaged[Any, Nothing, ZDequeue[RB, EB, B]]

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope of the managed to take a message from the hub each time.

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope of the managed to take a message from the hub each time.

Concrete methods

final def contramap[C](f: C => A): ZHub[RA, RB, EA, EB, C, B]

Transforms messages published to the hub using the specified function.

Transforms messages published to the hub using the specified function.

final def contramapM[RC <: RA, EC >: EA, C](f: C => ZIO[RC, EC, A]): ZHub[RC, RB, EC, EB, C, B]

Transforms messages published to the hub using the specified effectual function.

Transforms messages published to the hub using the specified effectual function.

final def dimap[C, D](f: C => A, g: B => D): ZHub[RA, RB, EA, EB, C, D]

Transforms messages published to and taken from the hub using the specified functions.

Transforms messages published to and taken from the hub using the specified functions.

final def dimapM[RC <: RA, RD <: RB, EC >: EA, ED >: EB, C, D](f: C => ZIO[RC, EC, A], g: B => ZIO[RD, ED, D]): ZHub[RC, RD, EC, ED, C, D]

Transforms messages published to and taken from the hub using the specified effectual functions.

Transforms messages published to and taken from the hub using the specified effectual functions.

final def filterInput[A1 <: A](f: A1 => Boolean): ZHub[RA, RB, EA, EB, A1, B]

Filters messages published to the hub using the specified function.

Filters messages published to the hub using the specified function.

final def filterInputM[RA1 <: RA, EA1 >: EA, A1 <: A](f: A1 => ZIO[RA1, EA1, Boolean]): ZHub[RA1, RB, EA1, EB, A1, B]

Filters messages published to the hub using the specified effectual function.

Filters messages published to the hub using the specified effectual function.

final def filterOutput(f: B => Boolean): ZHub[RA, RB, EA, EB, A, B]

Filters messages taken from the hub using the specified function.

Filters messages taken from the hub using the specified function.

final def filterOutputM[RB1 <: RB, EB1 >: EB](f: B => ZIO[RB1, EB1, Boolean]): ZHub[RA, RB1, EA, EB1, A, B]

Filters messages taken from the hub using the specified effectual function.

Filters messages taken from the hub using the specified effectual function.

final def map[C](f: B => C): ZHub[RA, RB, EA, EB, A, C]

Transforms messages taken from the hub using the specified function.

Transforms messages taken from the hub using the specified function.

final def mapM[RC <: RB, EC >: EB, C](f: B => ZIO[RC, EC, C]): ZHub[RA, RC, EA, EC, A, C]

Transforms messages taken from the hub using the specified effectual function.

Transforms messages taken from the hub using the specified effectual function.

final def toQueue: ZEnqueue[RA, EA, A]

Views the hub as a queue that can only be written to.

Views the hub as a queue that can only be written to.