https://kotlinlang.org logo
#compose
Title
# compose
b

bnvinay92

10/13/2023, 10:35 PM
Is there a way to check if the current composition has already been invalidated and a recompose is pending?
👀 1
🤔 1
z

Zach Klippenstein (he/him) [MOD]

10/14/2023, 10:11 PM
What are you trying to do?
1
b

bnvinay92

10/15/2023, 5:02 AM
I have a stateflow i'm creating via molecule and i'm trying to skip intermediate emissions if I i know it's already "stale".
z

Zach Klippenstein (he/him) [MOD]

10/15/2023, 1:35 PM
The simplest thing to do would be get the indirection out of the way and host your molecule composables in a UI composable - then you’ll get that behavior for free. If you can’t do that, for lifecycle reasons or something, then maybe there’s a way to get molecule to defer its recomposition pass until some external signal? Which you could wire up to the UI frame signal (eg via withFrameNanos).
I would also suggest asking in #squarelibraries, more of the maintainers are likely to be active there and might have better ideas.
👍 1
b

bnvinay92

10/15/2023, 2:49 PM
This stateflow is being consumed on ios too and would like to solve this for both. We were previously solving this (on a library based off square's workflow) by setting a flag whenever an action was received before render completes and re-render if set. That approach might still work but would like to delegate this to compose since it's already doing the book keeping.
z

Zach Klippenstein (he/him) [MOD]

10/16/2023, 2:56 AM
If Molecule lets you specify your own frame clock then you can just wrap whatever frame clock your platform uses. That’s what compose UI does.
j

jw

10/16/2023, 2:56 AM
Indeed it does
2 Views