MCPcopy Create free account
hub / github.com/Effect-TS/effect / timer

Function timer

packages/effect/src/ui/Query.ts:5326–5339  ·  view source on GitHub ↗
(ms: number, f: () => void)

Source from the content-addressed store, hash-verified

5324 }
5325 /** A `Clock` sleep. Returns its cancel. */
5326 const timer = (ms: number, f: () => void): () => void => {
5327 const fiber: Fiber.Fiber<any, any> = runFork(Effect.andThen(
5328 Effect.sleep(ms),
5329 Effect.sync(() => {
5330 timers.delete(fiber)
5331 if (!disposed) f()
5332 })
5333 ))
5334 timers.add(fiber)
5335 return () => {
5336 timers.delete(fiber)
5337 fiber.interruptUnsafe()
5338 }
5339 }
5340 const report = (problem: Problem.Any): void => {
5341 try {
5342 options.report(problem)

Callers 2

sleepFunction · 0.70
armIntervalFunction · 0.70

Calls 7

runForkFunction · 0.85
sleepMethod · 0.65
deleteMethod · 0.65
addMethod · 0.65
fFunction · 0.50
syncMethod · 0.45
interruptUnsafeMethod · 0.45

Tested by

no test coverage detected