( f: (entry: Request.Entry<A>) => Effect.Effect<Request.Success<A>, Request.Error<A>> )
| 437 | * @since 2.0.0 |
| 438 | */ |
| 439 | export const fromEffect = <A extends Request.Any>( |
| 440 | f: (entry: Request.Entry<A>) => Effect.Effect<Request.Success<A>, Request.Error<A>> |
| 441 | ): RequestResolver<A> => { |
| 442 | effect.interruptChildrenPatch() // ensure middleware is registered |
| 443 | return make((entries) => |
| 444 | Effect.callback<void>((resume) => { |
| 445 | const parent = effect.getCurrentFiber()! |
| 446 | let done = 0 |
| 447 | for (let i = 0; i < entries.length; i++) { |
| 448 | const entry = entries[i] |
| 449 | const fiber = effect.forkUnsafe(parent as any, f(entry), true) |
| 450 | fiber.addObserver((exit) => { |
| 451 | entry.completeUnsafe(exit) |
| 452 | done++ |
| 453 | if (done === entries.length) { |
| 454 | resume(effect.void) |
| 455 | } |
| 456 | }) |
| 457 | } |
| 458 | }) |
| 459 | ) |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Constructs a request resolver from a list of tags paired to functions, that takes |
nothing calls this directly
no test coverage detected