Dynamically Overwriting Config Options in Effect Typescript

I have this Config Tag

class MyServiceConfig extends Context.Tag('@myservice/config')<
  ScrapingBeeConfig,
  {
    readonly url: string;
    readonly apiKey: Redacted.Redacted<string>;
    readonly options: Record<string, string>;
  }
>() {}


and I populate it using a Layer.effect that reads from ENV using the Config api.

At runtime I want to have the option to overwrite / add / remove some of the options. Or to make it simpler, assume it is a boolean flag that I should be able to overwrite dynamically (for some effects) while most of them are using the default config.
Sort of like HttpClient.withTracerPropagation(false). Where I can disable some config for certain effects using HttpClient.

What's the best option here? Ideally it would be something like MyServiceConfig.withBooleanFlag(false).

Is there an example I can look into? Is this done by using FiberRefs?
Was this page helpful?