(effect: Effect.Effect<A, E, R>)
| 31 | }) |
| 32 | |
| 33 | export function batch<A, E, R>(effect: Effect.Effect<A, E, R>) { |
| 34 | return Effect.gen(function* () { |
| 35 | const current = yield* CurrentBatch |
| 36 | if (current) return yield* effect |
| 37 | const reloads = new Set<Reload>() |
| 38 | const result = yield* effect.pipe(Effect.provideService(CurrentBatch, reloads)) |
| 39 | yield* Effect.forEach(reloads, (reload) => reload(), { discard: true }) |
| 40 | return result |
| 41 | }) |
| 42 | } |
| 43 | |
| 44 | export interface Options<State, DraftApi> { |
| 45 | /** Creates the base value for initial state and every scoped-transform reload. */ |
no test coverage detected