Effect CommunityEC
Effect Community3y ago
48 replies
Victor Korzunin

Comparing two approaches for providing a dependent layer

Hello effect experts, I'd like to understand some detail regarding layers. What would be better approach of providing dependent layer:
const DefaultS3ClientInstanceLayer = Layer.effect(
  S3ClientInstanceTag,
  S3ClientConfigTag.pipe(
    Effect.map((config) => new S3Client(config)),
    Effect.provideLayer(DefaultS3ClientConfigLayer),
  ),
);
or
const DefaultS3ClientInstanceLayer = Layer.provide(
  DefaultS3ClientConfigLayer,
  Layer.effect(
    S3ClientInstanceTag,
    S3ClientConfigTag.pipe(Effect.map((config) => new S3Client(config))),
  ),
);
Was this page helpful?