LazyBind

A delegate class that implements ScopeComponent to provide a late-initialized scope. It acts as a placeholder for a Scope that will be injected later in the component's lifecycle. This is particularly useful in Android where context-dependent scopes cannot be created at property initialization time.

Usage (for Android):

class MyActivity : AppCompatActivity(), ScopeComponent<MyScope> by LazyBind() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
injectScope(lazy { createMyScope() })
// Now you can access scope.value
}
}

Parameters

T

The type of the Scope being delegated.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val scope: Lazy<T>

A lazy-initialized property that holds the Scope instance. Accessing this property before the scope is injected will result in an error.

Functions

Link copied to clipboard
open override fun injectScope(lazyScope: Lazy<T>)

Injects the actual Scope instance into the component. This method is designed to be called during the component's initialization phase (e.g., Activity.onCreate).

Link copied to clipboard
open override fun isInitialized(): Boolean

Checks if the scope has been injected and initialized.