Marcin Piekielny
04/12/2024, 6:44 AMviewModel.onCleared()
from Swift takes no effect and shared coroutine keeps running.
I checked the source code of the library and I noticed that KMMViewModel
in the appleMain
source set has empty onCleared
implementation. On the other hand the same class but int he otherMain
source sets cancels the Coroutine scope in onCleared
.
Do you know guys if this is an intentional implementation? If yes what is a recommended way to cancel this scope when given ViewModel is no more used by the iOS application?Rick Clephas
04/12/2024, 6:56 AMonCleared
function, but that shouldn’t make a difference in the behaviour.
The library will automatically cancel the CoroutineScope as soon as the Swift wrapper is deallocated.
Could you share some more details about your applications?
If the scope isn’t cancelled that probably means the application is still keeping a reference to the viewmodel (wrapper).Marcin Piekielny
04/12/2024, 2:31 PMonCleared
method explicitly and this is how I've performed my experiment.
Didn't thought that scope is cancelled automatically when the reference is lost.
Thanks for the answer and great work with this library kodee loving