viewModelScope

Lazily creates or retrieves a AndroidScopes.ViewModelScope for a specific ViewModel type T. This scope is tied to the lifecycle of the ViewModel, surviving configuration changes. The scope is automatically closed when the ViewModel is cleared.

If the ViewModel is not yet attached to an Activity, it creates and returns a new ViewModelScope. Otherwise, it returns the existing scope attached to the ViewModel retrieved from the ViewModelProvider.

Return

A Lazy delegate that provides the AndroidScopes.ViewModelScope.

Parameters

T

The type of the ViewModel this scope is for.

pathBuilder

A DSL block to define the path to the parent scope. Defaults to the root scope.