Understanding the difference between `Layer.provide` and `Effect.provide` is crucial for managing...

If you construct your Services like in the example below, the Live layer ist <Service, never, never> but the single functions have requirements, do you provide them directly or let them bubble up?
const make = Effect.gen(function* (_) {
    const sendSignature = (data: Bla) =>
        Effect.gen(function* () {
            const userSession = yield* UserService.getSessionData()
            //... do stuff
        }).pipe(Effect.withSpan('sendSignature'), Effect.provide(UserService.Live)) //<<<----- do you do this?
    const recieveSignatureUpdate = (data: FOO) => Effect.gen(function* () {
        const otherService = yield* OtherService.doWhatever()
                //.... do stuff
}).pipe(Effect.provide...) //<<<----- do you do this?
    return {
        sendSignature,
        recieveSignatureUpdate,
    } as const
}).pipe(Effect.withSpan('make'))

export class SigningService extends Effect.Tag('SigningService')<SigningService, Effect.Effect.Success<typeof make>>() {
    static readonly Live = make.pipe(Layer.scoped(this))
}

I think the concept and difference between
Layer.provide
and
Effect.provide
is not really clear to me 😦
Was this page helpful?