{"action":"created","issue":{"url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/810","repository_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines","labels_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/810/labels{/name}","comments_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/810/comments","events_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/810/events","html_url":"https://github.com/Kotlin/kotlinx.coroutines/issues/810","id":378586039,"node_id":"MDU6SXNzdWUzNzg1ODYwMzk=","number":810,"title":"Possibility to replace default dispatchers","user":{"login":"dmytrodanylyk","id":2836354,"node_id":"MDQ6VXNlcjI4MzYzNTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2836354?v=4","gravatar_id":"","url":"https://api.github.com/users/dmytrodanylyk","html_url":"https://github.com/dmytrodanylyk","followers_url":"https://api.github.com/users/dmytrodanylyk/followers","following_url":"https://api.github.com/users/dmytrodanylyk/following{/other_user}","gists_url":"https://api.github.com/users/dmytrodanylyk/gists{/gist_id}","starred_url":"https://api.github.com/users/dmytrodanylyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmytrodanylyk/subscriptions","organizations_url":"https://api.github.com/users/dmytrodanylyk/orgs","repos_url":"https://api.github.com/users/dmytrodanylyk/repos","events_url":"https://api.github.com/users/dmytrodanylyk/events{/privacy}","received_events_url":"https://api.github.com/users/dmytrodanylyk/received_events","type":"User","site_admin":false},"labels":[{"id":846419469,"node_id":"MDU6TGFiZWw4NDY0MTk0Njk=","url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/labels/design","name":"design","color":"8a9edb","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-08T05:37:26Z","updated_at":"2018-11-19T15:15:45Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"So Rx java has a way to inject scheduler _(RxJavaPlugins)_, is there a plan to have a similar thing for coroutines dispatchers?\r\n\r\n@gildor  \r\n> I would add +1 for this.\r\nReplacing dispatcher implementation is pretty common thing which of course can be solved by DI, but this adds not necessary boilerplate especially for functions and Inline classes (I have use case when would like to use Inline class to wrap blocking API with coroutines, but cannot because want to allow switch dispatcher)\r\nThis is also crucial for UI dispatcher and unit tests.\r\nI agree that in most cases it can be handled by DI but a way to replace default dispatchers sounds reasonable for me\r\n\r\nChristoph Sturm _(from slack)_\r\n> is there a blocking scope that i can use to inject into classes that i test and make them run like they were invoked with runBlocking?\r\nI have some classes that implement interfaces that are not suspending, so they have their own coroutine scope and use scope.launch {}. but in my tests it would be nice to run them blocking, or to be able to wait on the scope"},"comment":{"url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/comments/439927255","html_url":"https://github.com/Kotlin/kotlinx.coroutines/issues/810#issuecomment-439927255","issue_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/810","id":439927255,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTkyNzI1NQ==","user":{"login":"qwwdfsad","id":2780116,"node_id":"MDQ6VXNlcjI3ODAxMTY=","avatar_url":"https://avatars2.githubusercontent.com/u/2780116?v=4","gravatar_id":"","url":"https://api.github.com/users/qwwdfsad","html_url":"https://github.com/qwwdfsad","followers_url":"https://api.github.com/users/qwwdfsad/followers","following_url":"https://api.github.com/users/qwwdfsad/following{/other_user}","gists_url":"https://api.github.com/users/qwwdfsad/gists{/gist_id}","starred_url":"https://api.github.com/users/qwwdfsad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwwdfsad/subscriptions","organizations_url":"https://api.github.com/users/qwwdfsad/orgs","repos_url":"https://api.github.com/users/qwwdfsad/repos","events_url":"https://api.github.com/users/qwwdfsad/events{/privacy}","received_events_url":"https://api.github.com/users/qwwdfsad/received_events","type":"User","site_admin":false},"created_at":"2018-11-19T15:15:45Z","updated_at":"2018-11-19T15:15:45Z","author_association":"MEMBER","body":"Let me clarify: we are not going to implement it in the form of global settable dispatchers like `RxJavaPlugins` does. For a core library, the probability that other libraries will set these global variables is high and conflicts in such cases just cannot be reasonably resolved.\r\nThe fact that some global state which is used by literally every library builder does not make it easier.\r\n\r\nIf you want to have control over dispatchers, use dependency injection and inversion of control.\r\nScoped concurrency is here for the rescue as one doesn't have to specify dispatcher everywhere, only in scope declaration.\r\n\r\n>Maybe good solution would be to include IntelliJ warning/inspection to not override dispatchers in production code?\r\n\r\nInspections and warnings won't help here, because people will use it anyway (\"I get used to it in RxJava, so I can ignore this warning\")."}}
{"actor":{"display_login":"qwwdfsad"}}