Discussion on using `Effect.Service` with dynamic arguments for default logic configuration

Was looking at wrapping my head around passing args to
Effect.Service
and this seems like a nice pattern? What do you all think?

I've seen the documentation and others here suggest Context.tag is preferred where there is no sensible default but seems to me more accurate to say that
Effect.Service
can cover having default logic configurable by dynamic arguments (which wasn't how i intrepreted the docs initially)

https://effect.website/play/#e1235163fadf

// Allows dynamic configuration of the default implementation of the service
const config: Config = { name: 'John' }
const runnable = program.pipe(Effect.provide(Layer.mergeAll(Greeting.Default(config), Joke.Default(config))))
Effect.runFork(runnable)
Was this page helpful?