LocatorDef

izumi.distage.model.definition.LocatorDef
See theLocatorDef companion object

Attributes

Companion
object
Graph
Supertypes

Members list

Type members

Inherited classlikes

final class MutationContext

Use this to create utility functions that add bindings mutably to the current module, as opposed to creating new modules and including them.

Use this to create utility functions that add bindings mutably to the current module, as opposed to creating new modules and including them.

Example:

 import distage.{ClassConstructor, Tag, ModuleDef}
 import izumi.distage.model.definition.dsl.ModuleDefDSL

 trait RegisteredComponent
 class RegisteredComponentImpl extends RegisteredComponent

 def addAndRegister[T <: RegisteredComponent: Tag: ClassConstructor](implicit mutateModule: ModuleDefDSL#MutationContext): Unit = {
   new mutateModule.dsl {
     make[T]

     many[RegisteredComponent]
       .weak[T]
   }
 }

 new ModuleDef {
   addAndRegister[RegisteredComponentImpl]
 }

Attributes

Inherited from:
AbstractBindingDefDSL
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

override def finalizers[F[_] : TagK]: Seq[Finalizer[F]]

Attributes

Definition Classes
override def index: Map[DIKey, Any]

Attributes

Returns

Only instances directly contained in this Locator, NOT instances in its parent Locators. Returned keys will be unique.

Definition Classes
override def instances: Seq[IdentifiedRef]

Objects in this locator in order of creation

Objects in this locator in order of creation

Attributes

Returns

Only instances directly contained in this Locator, NOT instances in its parent Locators. Returned keys will be unique.

Definition Classes
override def isPrivate(key: DIKey): Boolean

Attributes

Definition Classes
override def meta: LocatorMeta

Attributes

Definition Classes
override def parent: Option[Locator]

Attributes

Definition Classes
override def plan: Plan

The plan that produced this object graph

The plan that produced this object graph

Attributes

Definition Classes

Inherited methods

final def allInstances: Seq[IdentifiedRef]

Attributes

Returns

ALL instances contained in this locator and in all the parent locators, including injector bootstrap environment. Returned keys may overlap if parent locators contain objects for the same key. Instances from parent locators will be earlier in the list than instances from this locator.

See also
Inherited from:
Locator
final inline def bindAllImplicits[I, N <: IndiscriminateFunctoidDummyImplicit](inline f: N ?=> Functoid[I]): Functoid[I]

Like bindImplicits, but converts even fully resolved implicits into Functoid parameters.

Like bindImplicits, but converts even fully resolved implicits into Functoid parameters.

This may not be what you want, because this will also capture global utility implicits such as DummyImplicit, ClassTag and scala.collection.Factory, and turn them into DI parameters.

Attributes

Inherited from:
FunctoidBindImplicitsVersionSpecific
final inline def bindImplicits[I, N <: UnresolvedOnlyFunctoidDummyImplicit](inline f: N ?=> Functoid[I]): Functoid[I]

Convert unresolved implicits in the following code block, lambda or a method reference into explicit parameters that will be resolved from the object graph, not the implicit context.

Convert unresolved implicits in the following code block, lambda or a method reference into explicit parameters that will be resolved from the object graph, not the implicit context.

Example:

 final case class X(a: Int, b: Double)

 // LAMBDA:

 make[X].from(bindImplicits {
   (i: Int) => X(i, implicitly[Double])
 }

 // transforms into:

 make[X].from {
   (i: Int, d: Double) => X(i, d)
 }

 // CODE BLOCK:

 make[X].from(bindImplicits {
   X(implicitly[Int], implicitly[Double])
 })

 // transforms into:

 make[X].from {
   (i: Int, d: Double) => X(i, d)
 }

 // METHOD REFERENCE:

 def createX(i: Int)(implicit d: Double, dx: DummyImplicit): X = X(i, d)

 make[X].from(bindImplicits {
   createX
 })

 // transforms into:

 make[X].from {
   (i: Int, d: Double) => createX(i)(using d, DummyImplicit.dummyImplicit)
 }

 // because search for DummyImplicit was __resolved__ in current implicit scope, it was taken from the implicit context,
 // not from the object graph!

Attributes

Note

This function is available inside ModuleDef DSL, but it can also be called outside of it as Functoid.bindImplicits

Inherited from:
FunctoidBindImplicitsVersionSpecific
final def depth: Int

Attributes

Inherited from:
Locator
final override def find[T : Tag](id: Identifier): Option[T]

Attributes

Definition Classes
Inherited from:
AbstractLocator
final override def find[T : Tag]: Option[T]

Attributes

Definition Classes
Inherited from:
AbstractLocator
final override def get[T : Tag](id: Identifier): T

Attributes

Throws
MissingInstanceException

if T @Id(id) is missing

Definition Classes
Inherited from:
AbstractLocator
final override def get[T : Tag]: T

Attributes

Throws
MissingInstanceException

if T is missing

Definition Classes
Inherited from:
AbstractLocator
final override def lookupInstance[T : Tag](key: DIKey): Option[T]

Attributes

Definition Classes
Inherited from:
AbstractLocator
final override def lookupInstanceOrThrow[T : Tag](key: DIKey): T

Attributes

Definition Classes
Inherited from:
AbstractLocator
final override def lookupRef[T : Tag](key: DIKey): Option[GenericTypedRef[T]]

Attributes

Definition Classes
Inherited from:
AbstractLocator
final override def lookupRefOrThrow[T : Tag](key: DIKey): GenericTypedRef[T]

Attributes

Definition Classes
Inherited from:
AbstractLocator
final inline protected def make[T]: BindDSL[T]

Attributes

Inherited from:
AbstractBindingDefDSLMacro
def render()(implicit ev: Renderable[Locator]): String

Attributes

Inherited from:
Locator
final def run[T](function: Functoid[T]): T

Run function filling all the arguments from the object graph.

Run function filling all the arguments from the object graph.

Works similarly to function bindings in izumi.distage.model.definition.ModuleDef.

 objects.run {
   (hellower: Hellower, bye: Byer) =>
     hellower.hello()
     byer.bye()
 }

Attributes

See also
Inherited from:
Locator
final def runOption[T](function: Functoid[T]): Option[T]

Same as run but returns None if any of the arguments could not be fulfilled

Same as run but returns None if any of the arguments could not be fulfilled

Attributes

Inherited from:
Locator
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Locator -> Any
Inherited from:
Locator