Package: effect
Module: TxQueue
Creates a new dropping TxQueue with the specified capacity that drops new items when full.
Details
This function returns a new TxQueue reference with dropping strategy. No existing TxQueue instances are modified.
Example (Creating dropping queues)
import { Effect, TxQueue } from "effect"
const program = Effect.gen(function*() {
// Create a dropping queue with capacity 2
const queue = yield* TxQueue.dropping<number>(2)
// Fill to capacity
yield* TxQueue.offer(queue, 1)
yield* TxQueue.offer(queue, 2)
// This will be dropped (returns false)
const accepted = yield* TxQueue.offer(queue, 3)
console.log(accepted) // false
})
Signature
declare const dropping: <A = never, E = never>(capacity: number) => Effect.Effect<TxQueue<A, E>>
Since v2.0.0