(
effect: Micro<A, E>,
options?: {
readonly signal?: AbortSignal | undefined
readonly scheduler?: MicroScheduler | undefined
} | undefined
)
| 4212 | * @category execution |
| 4213 | */ |
| 4214 | export const runFork = <A, E>( |
| 4215 | effect: Micro<A, E>, |
| 4216 | options?: { |
| 4217 | readonly signal?: AbortSignal | undefined |
| 4218 | readonly scheduler?: MicroScheduler | undefined |
| 4219 | } | undefined |
| 4220 | ): MicroFiberImpl<A, E> => { |
| 4221 | const fiber = new MicroFiberImpl<A, E>(CurrentScheduler.context( |
| 4222 | options?.scheduler ?? new MicroSchedulerDefault() |
| 4223 | )) |
| 4224 | fiber.evaluate(effect as any) |
| 4225 | if (options?.signal) { |
| 4226 | if (options.signal.aborted) { |
| 4227 | fiber.unsafeInterrupt() |
| 4228 | } else { |
| 4229 | const abort = () => fiber.unsafeInterrupt() |
| 4230 | options.signal.addEventListener("abort", abort, { once: true }) |
| 4231 | fiber.addObserver(() => options.signal!.removeEventListener("abort", abort)) |
| 4232 | } |
| 4233 | } |
| 4234 | return fiber |
| 4235 | } |
| 4236 | |
| 4237 | /** |
| 4238 | * Execute the `Micro` effect and return a `Promise` that resolves with the |
no test coverage detected