-
When collecting values as a state within a presenter , either using I've provided a small reproducible example here. In this example, a presenter is collecting a use case which returns a Result. When returning Result.Error, the presenter is re-created repeatedly. My question is, is this intended? We're actively porting a lot of our features from Android/ViewModels to KMP with Circuit, and heavily rely on I've also ran through a lot of our domain and noticed a lot of our values are marked as unstable, which seem fixable, but i'd like to understand if this needs to be addressed before migrating. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Just looking at the repro, think the bigger issue is that each invoke of the use case will be returning a new Flow. Which would also be unstable and cause more compositions. val result by useCase().collectAsRetainedState(null) It’s a subtle issue when using One option is to use a val result by
produceRetainedState<Result<*>?>(initialValue = null, key) {
useCase().collect { value = it }
} |
Beta Was this translation helpful? Give feedback.
Just looking at the repro, think the bigger issue is that each invoke of the use case will be returning a new Flow. Which would also be unstable and cause more compositions.
It’s a subtle issue when using
collectAs*
, where if theFlow
isn't a single instance it needs to remember too.One option is to use a
produce*State
to "capture" the use case invoke and remember it while its collected.