-
Notifications
You must be signed in to change notification settings - Fork 906
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
Use a direct dispatcher in Flow
-> Rx
conversions.
#592
base: main
Are you sure you want to change the base?
Conversation
1025f48
to
311ae10
Compare
* 3. [Coroutines/Flow vs add/remove listener (synchronous execution) #3506](https://github.com/Kotlin/kotlinx.coroutines/issues/3506) | ||
* <!-- spotless:on --> | ||
*/ | ||
internal object DirectDispatcher : CoroutineDispatcher() { |
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.
thanks for adding! wondering if this should be moved into another module (e.g. libraries/rib-coroutines)
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.
@psteiger friendly ping here ^
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.
Sorry I missed this comment.
I think it's best to have it in "core", because I believe the tendency is for rib-coroutine to cease to exist once we migrate fully to coroutines.
@tyvsmith in case you wanna confirm or deny ^
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.
np! I see, thanks for clarifying
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.
Lets move it to ribs-coroutines until we're ready to move all of it to core. Otherwise we're in a worse fragmented state.
What do you think if we update WorkerBinder default param value with Unconfined with this new DirectDispatcher? https://github.com/uber/RIBs/blob/main/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/WorkerBinder.kt#L78 |
@FranAguilera that's a good question I think we would be wise to do some benchmarks to measure performance impact of this change and also experiment internally on the safety (stackoverflow risk etc) |
@psteiger Sorry missed this comment earlier. I totally agree, we can put internal doc for steps on measuring impact of this change within our internal repo |
A direct dispatcher mimics the Rx always synchronous-by-default behavior (unless `subscribeOn`/`observeOn` is used), which is different to the `Dispatchers.Unconfined` behavior (default used by `Flow.asObservable`) which may form event loops for nested coroutines (asynchronous).
311ae10
to
760488c
Compare
A direct dispatcher mimics the Rx always synchronous-by-default behavior (unless
subscribeOn
/observeOn
is used), which is different to theDispatchers.Unconfined
behavior (default used byFlow.asObservable
) which may form event loops for nested coroutines (asynchronous).See Kotlin/kotlinx.coroutines#3760