Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rysh88
Copy link
Contributor

@rysh88 rysh88 commented Jul 29, 2025

Using SharedFlow can lead to ANRs when the consumer is slow and the producer emits on the main thread.
Replacing it reduces the likelihood of ANRs and improves traceability when they do occur.
This will be a seamless change outside the Interactor.

return rxCompletable(RibDispatchers.Unconfined + context) {
takeWhile { it < range.endInclusive }.collect()
takeWhile {
it == null || it < range.endInclusive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use something like CREATED for the initial state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to use null for now to minimize the change and if we do decide to remove the MutableSharedFlow, we can introduce the CREATED state.

public open val lifecycleFlow: SharedFlow<InteractorEvent>
get() = _lifecycleFlow

private var useStateFlow = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who sets this? I don't see it being set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed this. let me update it

@rysh88 rysh88 force-pushed the rubin/feature_replace_shared_flow_with_state_flow_interactor branch from d169715 to ccde6bf Compare August 5, 2025 19:00
private val useStateFlow = RibEvents.useStateFlowInteractorEvent

private val _lifecycleFlow: MutableSharedFlow<InteractorEvent?> =
if (useStateFlow)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use brackets if multi-line if-else

public open val lifecycleFlow: SharedFlow<InteractorEvent>
get() = _lifecycleFlow

private val useStateFlow = RibEvents.useStateFlowInteractorEvent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we can probably save an allocation here. Let's just use get() = RibEvents.useStateFlowInteractorEvent

@rysh88 rysh88 force-pushed the rubin/feature_replace_shared_flow_with_state_flow_interactor branch from ccde6bf to 2ffd489 Compare August 13, 2025 20:25
@rysh88 rysh88 force-pushed the rubin/feature_replace_shared_flow_with_state_flow_interactor branch from 2ffd489 to 586d0fe Compare August 13, 2025 21:29
@psteiger psteiger merged commit 134394c into uber:main Aug 13, 2025
4 checks passed
@rysh88 rysh88 deleted the rubin/feature_replace_shared_flow_with_state_flow_interactor branch August 13, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants