While reading about ZIO-config in 2.0.4, the following pattern to create services caught my eye. I am copying it here for easy lookup. Enjoy.
val myLayer: ZLayer[PaymentRepo, Nothing, MyService] =
ZLayer.scoped {
for {
repo <- ZIO.service[PaymentRepo]
config <- ZIO.config(MyServiceImpl.config)
ref <- Ref.make(MyState.Initial)
impl <- ZIO.succeed(new MyServiceImpl(config, ref, repo))
_ <- impl.initialize
_ <- ZIO.addFinalizer(impl.destroy)
} yield impl
}