Skip to content

Commit

Permalink
Add: Koin extension classes (stabilize scope)
Browse files Browse the repository at this point in the history
  • Loading branch information
machiav3lli committed Jan 10, 2025
1 parent 88b71c8 commit 1c6b716
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/machiav3lli/backup/utils/Koin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.machiav3lli.backup.utils

import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.ViewModel
import org.koin.androidx.compose.koinViewModel
import org.koin.core.component.getScopeId
import timber.log.Timber

open class NeoViewModel : ViewModel() {
init {
Timber.w("neoviewmodel@koinscope: ${getScopeId()}")
}
}

@Composable
inline fun <reified T : ViewModel> koinNeoViewModel() = koinViewModel<T>(
viewModelStoreOwner = LocalContext.current as ComponentActivity
)

0 comments on commit 1c6b716

Please sign in to comment.