Handling Optional Provisioning of Layers in Effect Typescript
Whats the best way to handle optional provisioning of layers?
I have an effect with an optional key value store dependency (Effect.serviceOption). A Browser local kvs is provided, but this, to the surprise of nobody, requires being in a browser.
Currently Im providing it by piping
effect => isBrowser() ? Effect.provide(effect, Layer) : effect
But this doesn’t strike me as very idiomatic
+ this dep is not tracked at the type level
Is there a notion of OptionalLayer? Would such a concept be useful?
Effect.provideIf(predicate, Layer) could then be a thing, and the dep is tracked at the type level instead of being hidden
I have an effect with an optional key value store dependency (Effect.serviceOption). A Browser local kvs is provided, but this, to the surprise of nobody, requires being in a browser.
Currently Im providing it by piping
effect => isBrowser() ? Effect.provide(effect, Layer) : effect
But this doesn’t strike me as very idiomatic
+ this dep is not tracked at the type level
Is there a notion of OptionalLayer? Would such a concept be useful?
Effect.provideIf(predicate, Layer) could then be a thing, and the dep is tracked at the type level instead of being hidden
