Cool. Seems like general concensus is yes. its bad...
# coroutines
c
Cool. Seems like general concensus is yes. its bad. I feel like someone should just write a lint rule or something to just completely prevent using statics (is that what capital D, Dispatchers is called?) 😂 Seems like you pretty much just never want them.
n
c
lmao. HOORAY
oh hadn't thought of this fun myFunc(dispatcher: CoroutineDispatcher = Dispatchers.IO) { coroutineScope(dispatcher) }
i guess thats a good middle ground for convenience and testability
j
I most often put these into DI framework in separate module, main, default and io dispatcher. And in test replace all of them with UnconfinedTestDispatcher or StandardTestDispatcher from kotlinx test. And inject these into all classes instead of juggling around everywhere :) Providing default values imo can sometimes be confusing. But for sure good middle ground.
☝️ 2
c
gotcha. thats what my plan was. but still learning so i like your advice as well Joel (especially with a ☝️from the one and only Ken Yee and Nicholas Doglio). thanks!
🙂 1
p
Problem with DI approach is it’s just awkward or undoable for top level functions, it only works fine for class Default parameter in top level functions is the way to go