Effect CommunityEC
Effect Community2y ago
4 replies
shaugh

Using a global variable for logging delay in an antipattern

Seems funny that the example at https://effect.website/docs/scheduling/built-in-schedules is an antipattern:
import { Effect } from "effect"
 
let start = new Date().getTime()
 
export const log = Effect.sync(() => {
  const now = new Date().getTime()
  console.log(`delay: ${now - start}`)
  start = now
})

shouldn't be mutating a global variable here, no?
A fully-fledged functional effect system for TypeScript with a rich standard library
Built-in Schedules – Effect
Was this page helpful?