MCPcopy
hub / github.com/Effect-TS/effect / next

Method next

packages/effect/src/internal/schedule.ts:165–201  ·  view source on GitHub ↗
(input: In)

Source from the content-addressed store, hash-verified

163 }
164
165 next(input: In): Effect.Effect<Out, Option.Option<never>, R> {
166 return pipe(
167 core.map(ref.get(this.ref), (tuple) => tuple[1]),
168 core.flatMap((state) =>
169 pipe(
170 Clock.currentTimeMillis,
171 core.flatMap((now) =>
172 pipe(
173 core.suspend(() => this.schedule.step(now, input, state)),
174 core.flatMap(([state, out, decision]) => {
175 const setState = ref.set(this.ref, [Option.some(out), state] as const)
176 if (ScheduleDecision.isDone(decision)) {
177 return setState.pipe(
178 core.zipRight(core.fail(Option.none()))
179 )
180 }
181 const millis = Intervals.start(decision.intervals) - now
182 if (millis <= 0) {
183 return setState.pipe(
184 core.zipRight(updateInfo(this.iterationMeta, now, input, out)),
185 core.as(out)
186 )
187 }
188 const duration = Duration.millis(millis)
189 return pipe(
190 setState,
191 core.zipRight(updateInfo(this.iterationMeta, now, input, out)),
192 core.zipRight(effect.sleep(duration)),
193 core.as(out)
194 )
195 })
196 )
197 )
198 )
199 )
200 )
201 }
202}
203
204/** @internal */

Callers

nothing calls this directly

Calls 10

updateInfoFunction · 0.85
startMethod · 0.80
pipeFunction · 0.70
mapMethod · 0.65
getMethod · 0.65
stepMethod · 0.65
setMethod · 0.65
pipeMethod · 0.65
failMethod · 0.65
sleepMethod · 0.65

Tested by

no test coverage detected