MCPcopy Index your code
hub / github.com/Effect-TS/effect / repeatEffectWithSchedule

Function repeatEffectWithSchedule

packages/effect/src/internal/stream.ts:5430–5451  ·  view source on GitHub ↗
(
  effect: Effect.Effect<A, E, R>,
  schedule: Schedule.Schedule<X, A0, R2>
)

Source from the content-addressed store, hash-verified

5428
5429/** @internal */
5430export const repeatEffectWithSchedule = <A, E, R, X, A0 extends A, R2>(
5431 effect: Effect.Effect<A, E, R>,
5432 schedule: Schedule.Schedule<X, A0, R2>
5433): Stream.Stream<A, E, R | R2> =>
5434 flatMap(
5435 fromEffect(Effect.zip(effect, Schedule.driver(schedule))),
5436 ([a, driver]) => {
5437 const provideLastIterationInfo = Effect.provideServiceEffect(
5438 Schedule.CurrentIterationMetadata,
5439 Ref.get(driver.iterationMeta)
5440 )
5441 return concat(
5442 succeed(a),
5443 unfoldEffect(a, (s) =>
5444 Effect.matchEffect(driver.next(s as A0), {
5445 onFailure: Effect.succeed,
5446 onSuccess: () =>
5447 Effect.map(provideLastIterationInfo(effect), (nextA) => Option.some([nextA, nextA] as const))
5448 }))
5449 )
5450 }
5451 )
5452
5453/** @internal */
5454export const retry = dual<

Callers 1

repeatWithScheduleFunction · 0.85

Calls 8

fromEffectFunction · 0.70
concatFunction · 0.70
succeedFunction · 0.70
unfoldEffectFunction · 0.70
zipMethod · 0.65
getMethod · 0.65
nextMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected