Hyperlinkv0.8.0-beta.28

Channel

Channel.fromArrayconsteffect/Channel.ts:665
<A>(array: ReadonlyArray<A>): Channel<A>

Creates a Channel that emits all elements from an array.

Example (Creating channels from arrays)

import { Channel } from "effect"

const channel = Channel.fromArray([1, 2, 3, 4, 5])
// Emits: 1, 2, 3, 4, 5
constructors
Source effect/Channel.ts:6655 lines
export const fromArray = <A>(array: ReadonlyArray<A>): Channel<A> =>
  fromPull(Effect.sync(() => {
    let index = 0
    return Effect.suspend(() => index >= array.length ? Cause.done() : Effect.succeed(array[index++]))
  }))
Referenced by 3 symbols