MCPcopy Index your code
hub / github.com/Effect-TS/effect / PullFromChild

Class PullFromChild

packages/effect/src/internal/channel/subexecutor.ts:48–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 * @internal
47 */
48export class PullFromChild<in out R> implements Subexecutor<R> {
49 readonly _tag: OP_PULL_FROM_CHILD = OP_PULL_FROM_CHILD
50
51 constructor(
52 readonly childExecutor: ErasedExecutor<R>,
53 readonly parentSubexecutor: Subexecutor<R>,
54 readonly onEmit: (value: unknown) => ChildExecutorDecision.ChildExecutorDecision
55 ) {
56 }
57
58 close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<unknown, never, R> | undefined {
59 const fin1 = this.childExecutor.close(exit)
60 const fin2 = this.parentSubexecutor.close(exit)
61 if (fin1 !== undefined && fin2 !== undefined) {
62 return Effect.zipWith(
63 Effect.exit(fin1),
64 Effect.exit(fin2),
65 (exit1, exit2) => pipe(exit1, Exit.zipRight(exit2))
66 )
67 } else if (fin1 !== undefined) {
68 return fin1
69 } else if (fin2 !== undefined) {
70 return fin2
71 } else {
72 return undefined
73 }
74 }
75
76 enqueuePullFromChild(_child: PullFromChild<R>): Subexecutor<R> {
77 return this
78 }
79}
80
81/**
82 * Execute `upstreamExecutor` and for each emitted element, spawn a child

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected