TPubSub overview
Added in v2.0.0
Table of contents
constructors
bounded
Creates a bounded TPubSub
with the back pressure strategy. The TPubSub
will retain messages until they have been taken by all subscribers, applying back pressure to publishers if the TPubSub
is at capacity.
Signature
export declare const bounded: <A>(requestedCapacity: number) => STM.STM<TPubSub<A>>
Added in v2.0.0
dropping
Creates a bounded TPubSub
with the dropping strategy. The TPubSub
will drop new messages if the TPubSub
is at capacity.
Signature
export declare const dropping: <A>(requestedCapacity: number) => STM.STM<TPubSub<A>>
Added in v2.0.0
sliding
Creates a bounded TPubSub
with the sliding strategy. The TPubSub
will add new messages and drop old messages if the TPubSub
is at capacity.
For best performance use capacities that are powers of two.
Signature
export declare const sliding: <A>(requestedCapacity: number) => STM.STM<TPubSub<A>>
Added in v2.0.0
unbounded
Creates an unbounded TPubSub
.
Signature
export declare const unbounded: <A>() => STM.STM<TPubSub<A>>
Added in v2.0.0
getters
capacity
Returns the number of elements the TPubSub
can hold.
Signature
export declare const capacity: <A>(self: TPubSub<A>) => number
Added in v2.0.0
isEmpty
Returns true
if the TPubSub
contains zero elements, false
otherwise.
Signature
export declare const isEmpty: <A>(self: TPubSub<A>) => STM.STM<boolean>
Added in v2.0.0
isFull
Returns true
if the TPubSub
contains at least one element, false
otherwise.
Signature
export declare const isFull: <A>(self: TPubSub<A>) => STM.STM<boolean>
Added in v2.0.0
isShutdown
Returns true
if shutdown
has been called, otherwise returns false
.
Signature
export declare const isShutdown: <A>(self: TPubSub<A>) => STM.STM<boolean>
Added in v2.0.0
size
Retrieves the size of the TPubSub
, which is equal to the number of elements in the TPubSub
. This may be negative if fibers are suspended waiting for elements to be added to the TPubSub
.
Signature
export declare const size: <A>(self: TPubSub<A>) => STM.STM<number>
Added in v2.0.0
models
TPubSub (interface)
Signature
export interface TPubSub<in out A> extends TQueue.TEnqueue<A> {
readonly [TPubSubTypeId]: {
readonly _A: Types.Invariant<A>
}
}
Added in v2.0.0
mutations
awaitShutdown
Waits until the TPubSub
is shutdown. The STM
returned by this method will not resume until the queue has been shutdown. If the TPubSub
is already shutdown, the STM
will resume right away.
Signature
export declare const awaitShutdown: <A>(self: TPubSub<A>) => STM.STM<void>
Added in v2.0.0
publish
Publishes a message to the TPubSub
, returning whether the message was published to the TPubSub
.
Signature
export declare const publish: {
<A>(value: A): (self: TPubSub<A>) => STM.STM<boolean>
<A>(self: TPubSub<A>, value: A): STM.STM<boolean>
}
Added in v2.0.0
publishAll
Publishes all of the specified messages to the TPubSub
, returning whether they were published to the TPubSub
.
Signature
export declare const publishAll: {
<A>(iterable: Iterable<A>): (self: TPubSub<A>) => STM.STM<boolean>
<A>(self: TPubSub<A>, iterable: Iterable<A>): STM.STM<boolean>
}
Added in v2.0.0
subscribe
Subscribes to receive messages from the TPubSub
. The resulting subscription can be evaluated multiple times to take a message from the TPubSub
each time. The caller is responsible for unsubscribing from the TPubSub
by shutting down the queue.
Signature
export declare const subscribe: <A>(self: TPubSub<A>) => STM.STM<TQueue.TDequeue<A>>
Added in v2.0.0
subscribeScoped
Subscribes to receive messages from the TPubSub
. The resulting subscription can be evaluated multiple times within the scope to take a message from the TPubSub
each time.
Signature
export declare const subscribeScoped: <A>(self: TPubSub<A>) => Effect.Effect<TQueue.TDequeue<A>, never, Scope.Scope>
Added in v2.0.0
symbols
TPubSubTypeId
Signature
export declare const TPubSubTypeId: typeof TPubSubTypeId
Added in v2.0.0
TPubSubTypeId (type alias)
Signature
export type TPubSubTypeId = typeof TPubSubTypeId
Added in v2.0.0
utils
shutdown
Interrupts any fibers that are suspended on offer
or take
. Future calls to offer*
and take*
will be interrupted immediately.
Signature
export declare const shutdown: <A>(self: TPubSub<A>) => STM.STM<void>
Added in v2.0.0