Hey guys, I've got a question about the internals ...
# orbit-mvi
b
Hey guys, I've got a question about the internals of Orbit, why is the
intent
function using
runBlocking
? What's the point of using a
CoroutineScope
when creating the
ContainerHost
like so
scope.container(...)
?
1
m
runBlocking
is there just to deliver the intent to the container channel’s buffer. We could replace it with something else really. The container is scoped according to the CoroutineScope - so if the CoroutineScope is cancelled, all in progress intents are cancelled as well.
If you’re using an Android ViewModel - it uses the ViewModel’s CoroutineScope.
it kind of happens under the hood there
let me know if you need more info @Benoît
b
Thanks for the info. I'm not using Android ViewModel because I'm doing a KMM project, but passing the scope isn't an issue anyways. And what's the difference between the scope used in
scope.container()
and the one passed in
Container.Settings(intentDispatcher = ...)
?
m
Dispatcher
!=
Scope
🙂
the dispatcher in the settings is there if you wanted to change the dispatcher the incoming intents are handled on.
to be honest this is there mostly for unit testing
I don’t see why you’d want to touch that outside of that use case
b
Yeah sorry my question was confusing 😅 a scope "contains" a dispatcher, is it ignored then?
Yep unit testing is exactly why I wanna know more about this 🙂
m
internally we do
private val scope = parentScope + settings.intentDispatcher
today i learned 1
🙏 1
b
aaah yeah that's what I needed to know!
Thanks a lot 😄
m
no probs