Hyperlinkv0.8.0-beta.28

Stream

Stream.fromArrayEffectconsteffect/Stream.ts:1232
<A, E, R>(effect: Effect.Effect<ReadonlyArray<A>, E, R>): Stream<
  A,
  Pull.ExcludeDone<E>,
  R
>

Creates a stream from an effect that produces an array of values.

When to use

Use when the array must be acquired from an Effect before the stream emits, and acquisition services or failures should be part of the stream.

Example (Creating a stream from an effect that produces an array of values)

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

const program = Effect.gen(function*() {
  const stream = Stream.fromArrayEffect(Effect.succeed(["Ada", "Grace"]))
  const values = yield* Stream.runCollect(stream)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ "Ada", "Grace" ]
constructors
Source effect/Stream.ts:12323 lines
export const fromArrayEffect = <A, E, R>(
  effect: Effect.Effect<ReadonlyArray<A>, E, R>
): Stream<A, Pull.ExcludeDone<E>, R> => unwrap(Effect.map(effect, fromArray)) as any