Skip to content

Instantly share code, notes, and snippets.

View thats-bot's full-sized avatar
🏠
Working from home

Serhii Ihnatiev thats-bot

🏠
Working from home
View GitHub Profile
@thats-bot
thats-bot / SharedGraphViewModel.kt
Created January 7, 2021 16:05
Koin implementation of sharedGraphViewModel with ability to use SavedStateHandle functional inside ViewModel
/**
* Usage:
* val viewModel by sharedGraphViewModel<CheckoutViewModel>(R.id.navigationCheckout)
*/
inline fun <reified VM : ViewModel> Fragment.sharedGraphViewModel(
@IdRes navGraphId: Int,
qualifier: Qualifier? = null,
noinline initialState: BundleDefinition = { Bundle() },
noinline parameters: ParametersDefinition? = null,
) = lazy(LazyThreadSafetyMode.NONE) {