I am currently getting a "java.lang.IllegalStateEx...
# compose
a
I am currently getting a "java.lang.IllegalStateException: Launcher has not been initialized". What am I doing wrong?
i
It looks like you're calling
launch
as part of recomposition. You should be doing imperative work like that in a
SideEffect
or other block
a
SideEffect worked!
awesome
thank you
a
You likely want to set this up differently anyway; auto-redirecting users to the system permission prompts is generally discouraged from a UX perspective, plus by using a SideEffect of recomposition you'll end up repeatedly performing that launch whenever this recomposes. You might consider showing some UI with a call to action and a button the user can click to show it or similar, or if you really want to do this auto-redirect, perform the check and launch only when the local LifecycleOwner hits ON_START or similar.
a
yea thats what I am wondering right now, I will try to only launch when in on start
a
@Ian Lake should we look into adding some things like `Lifecycle.eventsAsFlow()`/`Lifecycle.stateAsFlow()` or similar to lifecycle ktx? I feel like I write them for every app project I start and end up recommending patterns assuming their availability
2
a
mhm, I am stuck right now
Do you have a sample project I can take a look at?
the location requests are getting executed on every recomposition, so thats what I am currently trying to figure out
565 Views