Skip to content

Commit

Permalink
Fix defaut extra argument #1688
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgiuliani committed Nov 10, 2023
1 parent aac9846 commit 1b5988f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.koin.androidx.viewmodel.ext.android

import android.app.Activity
import androidx.activity.ComponentActivity
import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
Expand Down Expand Up @@ -66,10 +68,11 @@ inline fun <reified T : ViewModel> Fragment.getActivityViewModel(
noinline extrasProducer: (() -> CreationExtras)? = null,
noinline parameters: (() -> ParametersHolder)? = null,
): T {
val op = ownerProducer()
return resolveViewModel(
T::class,
ownerProducer().viewModelStore,
extras = extrasProducer?.invoke() ?: this.defaultViewModelCreationExtras,
op.viewModelStore,
extras = extrasProducer?.invoke() ?: (op as? ComponentActivity)?.defaultViewModelCreationExtras ?: this.defaultViewModelCreationExtras,
qualifier = qualifier,
parameters = parameters,
scope = getKoinScope()
Expand Down

0 comments on commit 1b5988f

Please sign in to comment.