Passing a function that returns an `Effect` to the `effect` property of `Effect.Service` is a val...

When using
Effect.Service
is it okay to pass a function that returns an Effect to the effect property to allow outside params to be passed in when the service is being provided?

Here is what I'm currently doing for a CMS service:
export class CMS extends Effect.Service<CMS>()("CMS", {
  effect: (draftMode: boolean) => Effect.gen(function*() {
    const accessToken = yield* Config.redacted("CONTENTFUL_ACCESS_TOKEN")
    const space = yield* Config.string("CONTENTFUL_SPACE_ID")

    const client = createClient({ 
      accessToken: Redacted.value(accessToken),
      space,
      host: draftMode ? "preview.contentful.com" : "cdn.contentful.com" 
    })

    return client
  })
}){}

const program = (draftMode: boolean) => Effect.gen(function*() {
  const cms = yield* CMS
}).pipe(Effect.provide(CMS.Default(draftMode))) 
Was this page helpful?