Hyperlinkv0.8.0-beta.28

Schedule

Schedule.passthroughconsteffect/Schedule.ts:1683
<Output, Input, Error, Env>(
  self: Schedule<Output, Input, Error, Env>
): Schedule<Input, Input, Error, Env>

Returns a new Schedule that outputs the inputs of the specified schedule.

Example (Passing inputs through as outputs)

import { Console, Effect, Schedule } from "effect"

// Create a schedule that outputs the inputs instead of original outputs
const inputSchedule = Schedule.passthrough(
  Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
)

const program = Effect.gen(function*() {
  let counter = 0
  yield* Effect.repeat(
    Effect.gen(function*() {
      counter++
      yield* Console.log(`Task ${counter} executed`)
      return `result-${counter}`
    }),
    inputSchedule
  )
})
mapping
export const passthrough = <Output, Input, Error, Env>(
  self: Schedule<Output, Input, Error, Env>
): Schedule<Input, Input, Error, Env> =>
  fromStep(effect.map(toStep(self), (step) => (now, input) =>
    Pull.matchEffect(step(now, input), {
      onSuccess: (result) => effect.succeed([input, result[1]]),
      onFailure: effect.failCause,
      onDone: () => Cause.done(input)
    })))