Providing Dependencies to Static Methods in Effect.Service<>

With Effect.Service<> if you provide a static method like "Test" (similar to the "Test", "Mock", "Live" pattern common with Context.Tag) is there a way to provide it Dependencies like you do in the Default implementation? I'm a bit confused.

I have a "ConfigService" whose Default implementation gets environment variables from the system, but also a "Dev" static method that I want to provide a hardcoded ".fromJson" ConfigProvider to.

// hardcoded json config provider
const JsonConf: ConfigSchema = {
  CONSUMER_KEY: "...",
  CONSUMER_SECRET: "...",
  API_ENDPOINT: "...",
};
const hardCodedConfFromJson = ConfigProvider.fromJson(JsonConf);
const hardCodedConfLayer = Layer.setConfigProvider(hardCodedConfFromJson);

// config service
class ConfigService extends Effect.Service<ConfigService>()("ConfigService", {
  effect: Effect.gen(function* (_) {
    const CONSUMER_KEY = yield* Config.string("CONSUMER_KEY");
    const CONSUMER_SECRET = yield* Config.string("CONSUMER_SECRET");
    const API_ENDPOINT = yield* Config.string("API_ENDPOINT");
    return { CONSUMER_KEY, CONSUMER_SECRET, API_ENDPOINT };
  }),
  // dependencies: [],
}) {
  static Dev = Effect.gen(function* (_) {
    const CONSUMER_KEY = yield* Config.string("CONSUMER_KEY");
    const CONSUMER_SECRET = yield* Config.string("CONSUMER_SECRET");
    const API_ENDPOINT = yield* Config.string("API_ENDPOINT");
    return { CONSUMER_KEY, CONSUMER_SECRET, API_ENDPOINT };
  });
  <-- HERE, HOW DO I GIVE THIS STATIC METHOD IT'S "DEPENDENCIES: []">
}
Was this page helpful?