Accessible

trait Accessible[R]

A simple, macro-less means of creating accessors from Services. Extend the companion object with Accessible[ServiceName], then simply call Companion(_.someMethod), to return a ZIO effect that requires the Service in its environment.

Example:

 trait FooService {
   def magicNumber: UIO[Int]
   def castSpell(chant: String): UIO[Boolean]
 }

 object FooService extends Accessible[FooService]

 val example: ZIO[Has[FooService], Nothing, Unit] =
   for {
     int  <- FooService(_.magicNumber)
     bool <- FooService(_.castSpell("Oogabooga!"))
   } yield ()
Companion:
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[R0, E, A](f: R => ZIO[R0, E, A])(implicit tag: Tag[R], isAny: IsAny[R0]): ZIO[Has[R], E, A]