abhishek maharajpet
abhishek maharajpet

Reputation: 626

Get shared viewmodel with constructor arguments between Activity and Fragment using Koin

I am using koin dependency injection. My Activity is in Java and Fragment is in Kotlin. The Viewmodel has constructor arguments.

Currently I am trying this in Activity

MyViewmodel viewmodel = get(MyViewmodel.class, null, () -> parametersOf(this));

And in Fragment

private val viewModel: MyViewmodel by sharedViewModel()

I am getting different instances. How to share a single instance here?

Upvotes: 1

Views: 1886

Answers (1)

Alexander
Alexander

Reputation: 551

I think you should check your initialization. See sample. Your question doesn't have enough information for a full answer.

Upvotes: 0

Related Questions