( self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>, onExit: (exit: Exit.Exit<OutDone, OutErr>, scope: Scope.Scope) => Pull.Pull<void, E, OutDone2, R> )
| 3397 | )) |
| 3398 | |
| 3399 | const repeatLoop = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, E, OutDone2, R>( |
| 3400 | self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>, |
| 3401 | onExit: (exit: Exit.Exit<OutDone, OutErr>, scope: Scope.Scope) => Pull.Pull<void, E, OutDone2, R> |
| 3402 | ): Channel<OutElem, E, OutDone2, InElem, InErr, InDone, Env | R> => |
| 3403 | fromTransform((upstream, scope) => |
| 3404 | Effect.sync(() => { |
| 3405 | let currentPull: Pull.Pull<OutElem, E, OutDone2, Env | R> | undefined |
| 3406 | const makePull = (): Pull.Pull<OutElem, E, OutDone2, Env | R> => { |
| 3407 | const runScope = Scope.forkUnsafe(scope) |
| 3408 | return Effect.flatMap(toTransform(self)(upstream, runScope), (pull) => { |
| 3409 | currentPull = Effect.catchCause(pull, (cause) => { |
| 3410 | const exit = Pull.doneExitFromCause(cause) as Exit.Exit<OutDone, OutErr> |
| 3411 | return Scope.close(runScope, exit).pipe( |
| 3412 | Effect.flatMap(() => onExit(exit, scope)), |
| 3413 | Effect.flatMap(makePull) |
| 3414 | ) |
| 3415 | }) |
| 3416 | return currentPull |
| 3417 | }) |
| 3418 | } |
| 3419 | return Effect.suspend(() => currentPull ?? makePull()) |
| 3420 | }) |
| 3421 | ) |
| 3422 | |
| 3423 | /** |
| 3424 | * Repeats this channel forever. |
no test coverage detected