https://kotlinlang.org logo
#koin
Title
# koin
p

Pedro Francisco de Sousa Neto

02/24/2023, 2:23 PM
Hello guys! We’ve a new issue created about ClosedScopeException. Basically, this piece of code
scope.close()
from
registerScopeForLifecycle
is running BEFORE activity
onDestroy
. So if developer is calling something injected in
onDestroy
, gets a crash. Any suggestions to handle this case? Because this start happen in our app when we bump version from
3.1.6
to
3.3.1
.
p

Pedro Alberto

02/25/2023, 5:51 PM
so I assume you are using
createActivityScope
when you say
Copy code
So if developer is calling something injected in onDestroy, gets a crash.
Can you give a sample ?
p

Pedro Francisco de Sousa Neto

02/27/2023, 6:44 PM
I’m using
ScopeActivity
. And yes, it’ll use
Copy code
fun ComponentActivity.activityScope() = lazy { createActivityScope() }
l

Landry Norris

03/01/2023, 5:30 PM
Maybe try to track with a boolean if the presenter is initialized? No need to load the presenter just to dispose it if it hasn’t been loaded yet.
p

Pedro Francisco de Sousa Neto

03/01/2023, 5:46 PM
I totally agree with you about to refactor. But the point is the crash is happening and was not expected to happen. Right now, I think my question was wrong. I’m not trying to fix the problem (it’s easy) but I want to know why the Koin code was changed the observer from
3.1.6
to
3.3.1
. It impacted a lot of activities to crash.
a

arnaud.giuliani

03/02/2023, 8:57 AM
let me check if I can move things around 👍
tracked the issue for 3.4.0 milestone
p

Pedro Francisco de Sousa Neto

03/02/2023, 5:19 PM
Thanks, @arnaud.giuliani! blob smile happy