Effect CommunityEC
Effect Community3y ago
5 replies
sjm

Approaching service injection and managing it with Effect

Sorry for a similar question to one I've asked before, but trying to get my head around the best way of approaching the service injection part of Effect and how best to manage it.

So I'm making a branch to demonstrate to the rest of the team the benefits Effect could have for our codebase. I think it's making a good showing so far, using Streams and Services to untangle some pretty knotty code.

However, when it comes to running the Effect I now have a bunch of stuff to provide, some from a separate package. It looks like this, and that's only after converting a very small part of our codebase:

Effect.provide(LiveState),
Effect.provide(Fixtuur.Configuration.Good.LiveGoodsService),
Effect.provide(Api.ProductsPerPart.ProductsPerPartServiceLive),
Effect.provide(Api.Product.ProductServiceLive),
Effect.provideService(Api.Http.Http, Api.Http.LiveHttp),
Effect.provide(Requests.ProductUrls.UrlsServiceLive),           Effect.provideService(Backpack.BackpackConfiguration, BackpackConfigLive),

(ignore the poor naming convention of Live being both a suffix and a prefix at the moment, this will be tidied up)

Would it make sense to 'pre-merge' some of these layers in the separate package? For example, LiveGoodsService relies on ProductsPerPartServiceLive, which relies on ProductServiceLive. Is it acceptable practice to combine these layers into one LiveGoodsService layer so that's all the dev at the end needs to provide?

Thanks!
Was this page helpful?