Hyperlinkv0.8.0-beta.28

Channel

Channel.toPubSubTakeconsteffect/Channel.ts:8563
(
  options:
    | {
        readonly capacity: "unbounded"
        readonly replay?: number | undefined
      }
    | {
        readonly capacity: number
        readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
        readonly replay?: number | undefined
      }
): <OutElem, OutErr, OutDone, Env>(
  self: Channel<
    Arr.NonEmptyReadonlyArray<OutDone>,
    OutErr,
    OutDone,
    unknown,
    unknown,
    unknown,
    Env
  >
) => Effect.Effect<
  PubSub.PubSub<Take.Take<OutElem, OutErr, OutDone>>,
  never,
  Env | Scope.Scope
>
<OutElem, OutErr, OutDone, Env>(
  self: Channel<
    Arr.NonEmptyReadonlyArray<OutElem>,
    OutErr,
    OutDone,
    unknown,
    unknown,
    unknown,
    Env
  >,
  options:
    | {
        readonly capacity: "unbounded"
        readonly replay?: number | undefined
      }
    | {
        readonly capacity: number
        readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
        readonly replay?: number | undefined
      }
): Effect.Effect<
  PubSub.PubSub<Take.Take<OutElem, OutErr, OutDone>>,
  never,
  Env | Scope.Scope
>

Converts a channel to a scoped PubSub of Take values.

Details

Emitted non-empty arrays are published as output Take values. When the channel ends, its final Exit is published so subscribers can observe completion or failure.

destructors
Source effect/Channel.ts:856353 lines
export const toPubSubTake: {
  (
    options: {
      readonly capacity: "unbounded"
      readonly replay?: number | undefined
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
      readonly replay?: number | undefined
    }
  ): <OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutDone>, OutErr, OutDone, unknown, unknown, unknown, Env>
  ) => Effect.Effect<
    PubSub.PubSub<Take.Take<OutElem, OutErr, OutDone>>,
    never,
    Env | Scope.Scope
  >
  <OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutElem>, OutErr, OutDone, unknown, unknown, unknown, Env>,
    options: {
      readonly capacity: "unbounded"
      readonly replay?: number | undefined
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
      readonly replay?: number | undefined
    }
  ): Effect.Effect<
    PubSub.PubSub<Take.Take<OutElem, OutErr, OutDone>>,
    never,
    Env | Scope.Scope
  >
} = dual(
  2,
  Effect.fnUntraced(function*<OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutElem>, OutErr, OutDone, unknown, unknown, unknown, Env>,
    options: {
      readonly capacity: "unbounded"
      readonly replay?: number | undefined
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
      readonly replay?: number | undefined
    }
  ) {
    const pubsub = yield* makePubSub<Take.Take<OutElem, OutErr, OutDone>>(options)
    yield* runForEach(self, (value) => PubSub.publish(pubsub, value)).pipe(
      Effect.onExit((exit) => PubSub.publish(pubsub, exit)),
      Effect.forkScoped
    )
    return pubsub
  })
)
Referenced by 1 symbols