Run Layer Effect Only When First Used in Code Base

Team,
Is it possible to run Layer effect only when first used in code base?

Ex:
export class TestService extends Effect.Service<TestService>()('app/Test', {
  effect: Effect.gen(function* () {
    yield* Console.log("Run this only when this service is used for the first time??";

    return {};
  })
})


Now, I have created a custom runtime with this layer provided. But the problem is, this layer is getting executed immediately, when creating runtime.

When the TestService is not used, the TestService effect shoudn't run at all. But when using the service, only then it should be loaded.

How can we do this?
Was this page helpful?