Hey Makisuo,
Just wanted to make a quick suggestion - I'd recommend not using accessors: true in your service definitions. When you directly use FooService.method inside of BarService.method, it makes BarService.method dependent on FooService. What you probably want instead is for services to depend on each other. i.e.
class FooService extends Effect.Service<FooService>()("FooService", {
accessors: true,
effect: Effect.gen(function*(){
return {
method: Effect.fn("FooService.method")(function*(){
yield* Effect.log("Hello")
})
} as const
})
}) {}
class BarService extends Effect.Service<BarService>()("BarService", {
dependencies: [FooService.Default],
effect: Effect.gen(function*(){
const fooService = yield* FooService
return {
method: Effect.fn("FooService.method")(function*(){
yield* fooService.method()
}), // this method has no requirements, as the layer constructor takes care of them
methodWithAccessor: Effect.fn("BarService.methodWithAccessor")(function*(){
yield* FooService.method()
}) // this method has a requirement which will have to be satisfied later
} as const
})
}) {}
Just thought this might help!
skills/effect-best-practices/SKILL.md
Line 82 in 1d9b8f9
Hey Makisuo,
Just wanted to make a quick suggestion - I'd recommend not using
accessors: truein your service definitions. When you directly useFooService.methodinside ofBarService.method, it makesBarService.methoddependent onFooService. What you probably want instead is for services to depend on each other. i.e.Just thought this might help!