threading and using different dispatchers for Stor...
# store
a
threading and using different dispatchers for Store: i see that store uses DefaultDispatcher by default, even when using .stream().flowOn(ioDispatcher) how can i change that so that all remote calls from my fetcher are part of ioDispatcher? should i move withContext(ioDispatcher) to fetcher? i would like to keep all dispatchers in Repository layer which is using .flowOn with store at the moment because we have multiple repository implementations, i don't want to add dispatchers everywhere. i dont see any info in the docs on this @Matthew Ramotar
do i still need to reference my dispatcher in flowOn() or is it not necessary?
m
If you want to verify the dispatcher, you can do
Copy code
Fetcher.of { key ->

  // DON'T ACTUALLY DO THIS IN PROD
  val interceptor = coroutineContext[ContinuationInterceptor]
  check(interceptor == ioDispatcher) { "Fetcher not on IO" }

  api.get(key)
}
https://discuss.kotlinlang.org/t/checking-that-a-coroutinescope-uses-the-correct-dispatcher/23386
.flowOn(ioDispatcher)
is the right mechanism so you don’t need to scatter
withContext(ioDispatcher)
👍 2