-
Notifications
You must be signed in to change notification settings - Fork 909
Replace the SharedFlow with a StateFlow in the Interactor class #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace the SharedFlow with a StateFlow in the Interactor class #651
Conversation
| return rxCompletable(RibDispatchers.Unconfined + context) { | ||
| takeWhile { it < range.endInclusive }.collect() | ||
| takeWhile { | ||
| it == null || it < range.endInclusive |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
d169715 to
ccde6bf
Compare
| private val useStateFlow = RibEvents.useStateFlowInteractorEvent | ||
|
|
||
| private val _lifecycleFlow: MutableSharedFlow<InteractorEvent?> = | ||
| if (useStateFlow) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
ccde6bf to
2ffd489
Compare
… the ANR stacktraces and reduce ANRs
2ffd489 to
586d0fe
Compare
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.