Wrapper Function with optional context
Hello everyone! I'm new to Effect so sorry if my question might be stupid.
I'm trying to create a wrapper function (foo in the example) for an existing codebase that, given a function f that returns an effect, returns a new effect that does some stuff with the f() effect.
I want to make it so that the f() effect can either require a context or not; what i am currently doing is supply the context with Effect.provideContext to f() if the context is provided to foo, otherwise not.
What i want to achieve, in the following example, is for both bar1 and bar2 to be of type Effect<never, ...>, but bar1 is currently of type Effect<TestService, ...>.
Here's the example code:
Is there a way to achieve this? Or maybe a better solution, since in this case, if i forget to pass the context and f() requires it it crashes. Thank you!
I'm trying to create a wrapper function (foo in the example) for an existing codebase that, given a function f that returns an effect, returns a new effect that does some stuff with the f() effect.
I want to make it so that the f() effect can either require a context or not; what i am currently doing is supply the context with Effect.provideContext to f() if the context is provided to foo, otherwise not.
What i want to achieve, in the following example, is for both bar1 and bar2 to be of type Effect<never, ...>, but bar1 is currently of type Effect<TestService, ...>.
Here's the example code:
Is there a way to achieve this? Or maybe a better solution, since in this case, if i forget to pass the context and f() requires it it crashes. Thank you!
