Hey guys! I want to understand what motived a par...
# koin-contributors
p
Hey guys! I want to understand what motived a particular change in this commit. Specific looking for this block of code: FROM
Copy code
init {
[...]
   lifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
            override fun onCreate(owner: LifecycleOwner) {
                createScope()
            }
            override fun onDestroy(owner: LifecycleOwner) {
                logger.debug("Closing scope: $_scope for $lifecycleOwner")
                if (_scope?.closed == false) {
                    _scope?.close()
                }
                _scope = null
            }
})
[...]
}
TO
Copy code
internal fun LifecycleOwner.registerScopeForLifecycle(
    scope: Scope
) {
    lifecycle.addObserver(
        object : DefaultLifecycleObserver {
            override fun onDestroy(owner: LifecycleOwner) {
                super.onDestroy(owner)
                scope.close()
            }
        }
    )
}
Crashes with
ClosedKoinException
increased in our app with Koin
3.3.1
(with the TO/new code) that wasn’t happening with
3.1.6
(with FROM/old code). I think this code change was the cause, but I’m not sure yet. We’re analyzing! Thanks for attention!
a
Problem in previous versions, the Fragment lifecycle was not really attached. Where does it crash?
p
Hum… unfortunately keep crashing. I’ll try to extract this piece of code as a sample to share with you, guys.. Spoiler: it’s happen in fragment lifecycle when is inside an
FragmentStateAdapter
.
a
👀
if you can extract a small pice of that, I can manage to help