Skip to content

Instantly share code, notes, and snippets.

View donglua's full-sized avatar
😎
Haha

鲁大师 donglua

😎
Haha
View GitHub Profile
@rharter
rharter / Scoped.kt
Last active August 12, 2024 09:48
A kotlin property delegate to scope any object to an android lifecycle. Blog post at https://ryanharter.com/blog/easy-android-scopes/
import androidx.lifecycle.get
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
/**
* Returns a property delegate to access the wrapped value, which will be retained for the
* duration of the lifecycle of this [ViewModelStoreOwner].
*