Hyperlinkv0.8.0-beta.28

Sink

Sink.unwrapconsteffect/Sink.ts:1895
<A, In, L, E, R, R2>(
  effect: Effect.Effect<Sink<A, In, L, E, R2>, E, R>
): Sink<A, In, L, E, Exclude<R, Scope.Scope> | R2>

Creates a sink produced from a scoped effect.

Example (Unwrapping a sink effect)

import { Console, Effect, Sink, Stream } from "effect"

// Create a sink from an effect that produces a sink
const sinkEffect = Effect.succeed(
  Sink.forEach((item: number) => Console.log(`Item: ${item}`))
)
const sink = Sink.unwrap(sinkEffect)

// Use it with a stream
const stream = Stream.make(1, 2, 3)
const program = Stream.run(stream, sink)

Effect.runPromise(program)
// Output:
// Item: 1
// Item: 2
// Item: 3
constructors
Source effect/Sink.ts:18953 lines
export const unwrap = <A, In, L, E, R, R2>(
  effect: Effect.Effect<Sink<A, In, L, E, R2>, E, R>
): Sink<A, In, L, E, Exclude<R, Scope.Scope> | R2> => fromChannel(Channel.unwrap(Effect.map(effect, toChannel)))
Referenced by 1 symbols