import type { Decision } from "@effect/core/io/Schedule/Decision" import { makeWithState } from "@effect/core/io/Schedule/operations/_internal/makeWithState" /** * Returns a new schedule that applies the current one but runs the specified * effect for every decision of this schedule. This can be used to create * schedules that log failures, decisions, or computed values. * * @tsplus static effect/core/io/Schedule.Aspects onDecision * @tsplus pipeable effect/core/io/Schedule onDecision */ export function onDecision( f: (state: State, out: Out, decision: Decision) => Effect ) { return (self: Schedule): Schedule => makeWithState( self.initial, (now, input, state) => self.step(now, input, state).flatMap(([state, out, decision]) => f(state, out, decision).as([state, out, decision]) ) ) }