Effect CommunityEC
Effect Community8mo ago
3 replies
Alex Dixon

Effect.Service and writing to interfaces

Hello!

If I want various implantations of User, where core business logic only depends on some implementation of User, and I might provide that as UserLive, UserTest, etc., how does Effect.Service fit in? Or does it?

If I define User as an Effect.Service, I can derive the interface from its return value and provide a default (Live) implementation as the effect key. When providing layers I can do User.Default which provides User.

Alternate implementations like UserTest can be written as an Effect.Service that returns User.of, which ensures they satisfy the User interface. However, UserTest.Default satisfies the UserTest tag, not User.

Should alternate implementations be defined with Effect.Service and assigned to the tag of the interface they implement at layer provide time?

Is the idea that Effect.Service defines a default implementation for an interface it defines?
Was this page helpful?