https://kotlinlang.org logo
#compose-android
Title
# compose-android
j

Jonas

11/13/2023, 9:25 AM
👋 I have a question regarding
collectAsStateWithLifecycle()
. Could it be an issue to call this on the same state flow multiple times in different locations? (Maybe because the underlying produce state gets the same key?) We currently have some flaky tests and I figured out that some unused
collectAsStateWithLifecycle()
(consumed value is in test case mocked and used subvalue always false) causes the other
collectAsStateWithLifecycle()
to not launch again. Tldr: If I remove a call to
collectAsStateWithLifecycle()
in one place the other place gets called reliable.
(Maybe because the underlying produce state gets the same key?)
Just copy pasted the implementation of
collectAsStateWithLifecycle()
and added a second key to the produce state function: same issue.
I “solved” it now with moving all to the same place for the time being. But would be nice to know why this is happening.
z

Zach Klippenstein (he/him) [MOD]

11/13/2023, 2:24 PM
Can you make a minimal reproducer? They should be completely independent
3 Views