Colton Idle
04/17/2023, 12:37 PMremember
.
But wouldn't a launched effect also serve a similar purpose if I only want something to recompute if x changes?
i.e.
val someValue = remember(x) { someHeavyCalculation() }
vs something like
val someValue = null
LaunchedEffect(x){
someValue = someHeavyCalculation()
}
myanmarking
04/17/2023, 12:43 PMmyanmarking
04/17/2023, 12:43 PMFilip Wiesner
04/17/2023, 12:50 PMsomeValue
would have to be mutableStateOf
for this to work (apart from it being val
instead of var
)Filip Wiesner
04/17/2023, 12:53 PMDoes launched effect runs right away in the same frameCorrect me if I'm wrong but I think that
LaunchedEffect
and all other effects run after successful composition so all changes made in any effect would be only visible in next frame.myanmarking
04/17/2023, 12:55 PMFilip Wiesner
04/17/2023, 1:00 PMSideEffect
. I am actually not sure now 😅vide
04/17/2023, 1:15 PMSideEffect
. I think LaunchedEffect
runs interleaved with the composition 🤔vide
04/17/2023, 1:16 PMLaunchedEffect
will probably fail as its not in the tree yetStylianos Gakis
04/17/2023, 2:08 PMonDispose
because they want this to run instantly and not with 1 frame delay.
Relevant thread here
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1622560036078600?thread_ts=1622556885.065600&cid=CJLTWPH7S
and here https://kotlinlang.slack.com/archives/CJLTWPH7S/p1674253277230959?thread_ts=1673947731.751509&cid=CJLTWPH7S
and here https://kotlinlang.slack.com/archives/CJLTWPH7S/p1650034947332099?thread_ts=1650031631.129979&cid=CJLTWPH7Svide
04/17/2023, 2:47 PMvide
04/17/2023, 2:55 PMLaunchedEffect
? I would imagine the nodes are registered in the tree by the time the previous frame is done