icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development

Home Page:https://moko.icerock.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ViewModel calls init block, functions two times when they are called from screen

Mukhammaddin6567 opened this issue · comments

Hi, Moko team.
I got the issue. It is when i call view model , its init block called twice. then when i use one of the functions inside viewmodel it works twice too

hi. i think you have two instances of same viewmodel class. just add println("vm: $this") to see that it's not same object

@Alex009 objects are the same. I already did it

init block can't be called twice in one object. it's kotlin behaviour, not library.
can you prepare sample repository with this bug?

@Alex009 okay I will do it as soon as possible

we're providing viewmodel through koin... can this be due to koin? Do you have sample usage with koin?

@Alex009 Hi. Can you check your gmail?

@Mukhammaddin6567 i check my email but not see any mails. are you send something?
did you found reason of bug?

@Alex009 Hi. I found what is the problem. it's not related to moko-mvvm.

@Alex009 yes I found reason of bug. It was ktor problem