Module / v2.0.0-beta.7

@typed/fx/Sink

48 unique exports available through this public import path, including their members and aliases.

import * as Sink from "@typed/fx/Sink";

Collecting values

  • collect

    function

    Collects all values into an array. Pass a Ref<ReadonlyArray<A>> (e.g. Ref.make([])); after running, read the result with Ref.get(ref).

  • head

    function

    Keeps only the first value. Pass a Ref<Option.Option<A>> (e.g. Ref.make(Option.none())); after running, read the result with Ref.get(ref).

  • last

    function

    Keeps only the last value. Pass a Ref<Option.Option<A>> (e.g. Ref.make(Option.none())); after running, read the result with Ref.get(ref).

  • reduce

    function

    Reduces values into a single result using a pure function. Pass a Ref<B> (e.g. from Ref.make(initial)); after running, read the result with Ref.get(ref).

  • reduceEffect

    function

    Reduces values into a single result using an effectful function. Pass a Ref<B>; after running, read the result with Ref.get(ref). If the reducer effect fails, the ref is left unchanged (Sink onSuccess is typed as never failing).

Consumer contracts

  • Sink

    interface

    Consumes pushed successes and failures through effectful callbacks.

Failure handling

  • exit

    variable

    Materializes both sink channels as successful Effect Exit values.

  • flip

    variable

    Exchanges a sink’s typed success and failure channels.

  • mapError

    function

    Maps the error channel of a sink using the provided function. Failures are mapped via Cause.map; defects and interrupts are preserved.

  • skipInterrupt

    variable

    Suppresses failure causes made entirely of interruption reasons.

Operator options

  • Bounds

    interface

    Zero-based skip count and maximum take count used by slice.

Selecting inputs

  • compact

    function

    Forwards Some values and discards None values.

  • filter

    function

    Filters values before they reach the sink using a predicate function.

  • filterEffect

    variable

    Runs an effectful predicate and forwards inputs for which it succeeds with true.

  • filterMap

    function

    Filters and transforms values before they reach the sink using a function that returns an Option.

  • filterMapEffect

    variable

    Runs an Effect for each input and forwards its optional successful value.

Sink construction

  • make

    function

    Creates a Sink from success and failure callbacks.

Sink services

  • Service

    function

    Defines a class-shaped Effect Context service for a Sink.

  • Sink.Class

    interface

    Constructor-shaped Context service returned by Sink.Service.

  • Sink.Service

    interface

    Describes a Sink available through an Effect Context service.

Stateful delivery

  • Sink.WithState

    interface

    An early-exit sink with a mutable Effect Ref for consumer-local state.

  • Sink.WithStateSemaphore

    interface

    An early-exit sink with serialized effectful access to consumer-local state.

  • filterMapLoop

    variable

    Threads pure state through successes and optionally forwards a derived value.

  • filterMapLoopEffect

    variable

    Threads state through an effectful success transition and optionally forwards its value.

  • loop

    variable

    Threads pure state through successful inputs and forwards one derived value per input.

  • loopEffect

    variable

    Threads state through an effectful success transformation and forwards one value on success.

  • withState

    function

    Runs a callback with an early-exit sink and a private Effect Ref initialized to state.

  • withStateSemaphore

    function

    Runs a callback with private state whose effectful reads and writes are serialized.

Stateful failure handling

  • filterMapLoopCause

    variable

    Threads pure state through failures and optionally forwards a transformed cause.

  • filterMapLoopCauseEffect

    function

    Threads state through an effectful failure transition and optionally forwards a cause.

  • loopCause

    variable

    Threads pure state through failure causes and forwards one transformed cause per failure.

  • loopCauseEffect

    variable

    Threads state through an effectful failure transformation.

Stopping delivery

  • Sink.WithEarlyExit

    interface

    A sink that can ask its producer callback to stop early.

  • dropAfter

    variable

    Runs a producer callback until the first matching value has been forwarded.

  • slice

    variable

    Runs a producer callback through a bounded view of a sink.

  • withEarlyExit

    function

    Runs a producer-style callback with a sink that can complete the surrounding Effect early.

Transforming inputs

  • map

    function

    Transforms values before they reach the sink using a pure function.

  • mapEffect

    variable

    Runs an Effect for each input and forwards its successful value to the sink.

  • mapInput

    variable

    Alias for map, named for the input-side direction of the transformation.

  • mapInputEffect

    variable

    Alias for mapEffect, named for the input-side direction of the effectful transformation.

  • tapEffect

    variable

    Runs an effectful observation before forwarding each successful input unchanged.

Type contracts

  • Error

    type-alias

    Alias of Sink.Error for direct imports.

  • Services

    type-alias

    Alias of Sink.Services for direct imports.

  • Sink.Any

    type-alias

    Matches any Sink when its channels do not need to be preserved.

  • Sink.Error

    type-alias

    Extracts the typed error carried by causes consumed by a Sink.

  • Sink.Services

    type-alias

    Extracts the Effect services required by a Sink’s callbacks.

  • Sink.Success

    type-alias

    Extracts the successful input type consumed by a Sink.

  • Success

    type-alias

    Alias of Sink.Success for direct imports.