How to Provide a Dependency Layer to a Service Without Inlining Functions

Quick question about using a dependency within a layer. I have the following definition:

export const CheckoutLive = Layer.succeed(
  Checkout,
  Checkout.of({
    initiate,
  }),
).pipe(Layer.provide(InfrastructureLive));


initiate has this signature:

initiate: () => Effect<{...}, InitiateCheckoutSessionError, CookieAdapter>


whereas CookieAdapter is a layer in the InfrastructureLive layer. My initial thought was, that I can provide this layer to the CheckoutLive layer as described above, but this doesn't work.

How can I make the CookieAdapter available without defining the CheckoutLive layer with Layer.effect (as this would lead me to inlining the initiate function in there which would result in a huge service, when it grows)?

Any pointer is highly appreciated πŸ™‚
Was this page helpful?