effect-io-ai

Package: effect
Module: Channel

Channel.sync

Creates a Channel that emits a single value computed by a lazy evaluation.

Example (Computing values lazily)

import { Channel } from "effect"

let requests = 0

const channel = Channel.sync(() => {
  requests += 1
  return `request-${requests}`
})
// Emits "request-1" when the channel runs for the first time

Signature

declare const sync: <A>(evaluate: LazyArg<A>) => Channel<A>

Source

Since v2.0.0