android-beans / rocks.frieler.android.beans.scopes.singleton / SingletonScopedFactoryBean / lazyInstantiated

lazyInstantiated

@JvmStatic fun <T : Any> lazyInstantiated(type: Class<T>, producer: () -> T): BeanDefinition<SingletonScopedFactoryBean<*>>

Provides a BeanDefinition for a SingletonScopedFactoryBean that produces a bean of the given type using the given producer without dependencies.

Since beans are singletons by default, this has the effect of a lazy instantiation.

Parameters

type - the type of bean produced

producer - the producer to lazily create the actual bean

Parameters

Return
a BeanDefinition for a SingletonScopedFactoryBean

@JvmStatic fun <T : Any> lazyInstantiated(type: Class<T>, producer: BeansProvider.() -> T): BeanDefinition<SingletonScopedFactoryBean<*>>

Provides a BeanDefinition for a SingletonScopedFactoryBean that produces a bean of the given type using the given producer with dependencies.

Since beans are singletons by default, this has the effect of a lazy instantiation.

Parameters

type - the type of bean produced

producer - the producer to lazily create the actual bean

Parameters

Return
a BeanDefinition for a SingletonScopedFactoryBean