Singleton

class Singleton<C : Any, T : Any>(scope: Scope<C>, contextType: TypeToken<in C>, explicitContext: Boolean, createdType: TypeToken<out T>, refMaker: RefMaker?, sync: Boolean, creator: NoArgBindingDI<C>.() -> T) : NoArgDIBinding<C, T>

Singleton Binding: will create an instance on first request and will subsequently always return the same instance.

Parameters

T

The created type.

createdType

The type of the created object, used for debug print only.

creator

The function that will be called the first time an instance is requested. Guaranteed to be called only once. Should create a new instance.

Constructors

Singleton
Link copied to clipboard
common
fun <C : Any, T : Any> Singleton(scope: Scope<C>, contextType: TypeToken<in C>, explicitContext: Boolean, createdType: TypeToken<out T>, refMaker: RefMaker? = null, sync: Boolean = true, creator: NoArgBindingDI<C>.() -> T)
The created type.

Functions

factoryFullName
Link copied to clipboard
common
open override fun factoryFullName(): String
The full(er) name of this factory, used for debug print only.
factoryName
Link copied to clipboard
common
open override fun factoryName(): String
The name of this factory, used for debug print only.
getFactory
Link copied to clipboard
common
open override fun getFactory(key: DI.Key<C, Unit, T>, di: BindingDI<C>): (Unit) -> T

Properties

argType
Link copied to clipboard
common
open override val argType: TypeToken<Unit>
The type of the argument this factory will function for.
contextType
Link copied to clipboard
common
open override val contextType: TypeToken<in C>
The type of contexts that are to be set when using this factory.
copier
Link copied to clipboard
common
open override val copier: DIBinding.Copier<C, Unit, T>
A copier that is responsible for copying / resetting the binding.
createdType
Link copied to clipboard
common
open override val createdType: TypeToken<out T>
The type of the created object, used for debug print only.
creator
Link copied to clipboard
common
val creator: NoArgBindingDI<C>.() -> T
The function that will be called the first time an instance is requested.
description
Link copied to clipboard
common
open val description: String
The description of this factory (using simple type names), used for debug print only.
fullDescription
Link copied to clipboard
common
open val fullDescription: String
The description of this factory (using full type names), used for debug print only.
scope
Link copied to clipboard
common
open override val scope: Scope<C>
The scope used by this factory, if any
supportSubTypes
Link copied to clipboard
common
open val supportSubTypes: Boolean
Whether this bindings supports subtype handling.
sync
Link copied to clipboard
common
val sync: Boolean = true