( all: Iterable<Eff> )
| 1455 | * @category sequencing |
| 1456 | */ |
| 1457 | export const raceAllFirst = <Eff extends Micro<any, any, any>>( |
| 1458 | all: Iterable<Eff> |
| 1459 | ): Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>> => |
| 1460 | withMicroFiber((parent) => |
| 1461 | async((resume) => { |
| 1462 | let done = false |
| 1463 | const fibers = new Set<MicroFiber<any, any>>() |
| 1464 | const onExit = (exit: MicroExit<any, any>) => { |
| 1465 | done = true |
| 1466 | resume(fibers.size === 0 ? exit : flatMap(fiberInterruptAll(fibers), () => exit)) |
| 1467 | } |
| 1468 | |
| 1469 | for (const effect of all) { |
| 1470 | if (done) break |
| 1471 | const fiber = unsafeFork(parent, interruptible(effect), true, true) |
| 1472 | fibers.add(fiber) |
| 1473 | fiber.addObserver((exit) => { |
| 1474 | fibers.delete(fiber) |
| 1475 | onExit(exit) |
| 1476 | }) |
| 1477 | } |
| 1478 | |
| 1479 | return fiberInterruptAll(fibers) |
| 1480 | }) |
| 1481 | ) |
| 1482 | |
| 1483 | /** |
| 1484 | * Returns an effect that races two effects, yielding the value of the first |
no test coverage detected
searching dependent graphs…