InstanceLifecycleManager

class InstanceLifecycleManager<T>(onCreateInstance: (context: Context) -> T, onDestroyInstance: (instance: T) -> Unit)

This class can be used to manage the lifecycle of an instance. onCreateInstance will be called to notify that an instance has been requested and should provide a new instance of T. onDestroyInstance will be called when all LifecycleOwners associated to an instance are destroyed.

Constructors

Link copied to clipboard
fun <T> InstanceLifecycleManager(onCreateInstance: (context: Context) -> T, onDestroyInstance: (instance: T) -> Unit)

Functions

Link copied to clipboard
fun getInstance(context: Context, lifecycleOwner: LifecycleOwner): T