I am building an Android SDK in Kotlin that would be consumed by both Kotlin and Java users. It relies of common language patterns for Java & Kotlin like callbacks for async operations. In order to improve DX for Kotlin coroutines users I want to add modified versions of various callback operations to use Kotlin's suspending functions, Flows, etc.
I see that the common pattern, used by e.g. Android KTX or OkHttp, is to put coroutines overloads in a separate package, often named xxx-ktx
or xxx-coroutines
.
1. Are there any downsides of including coroutines support in the main library package?
Afaik it might increase method count, which might DEX method limit, but this could be addressed by proper Pro-guard config to allow removing unused coroutine related methods.
2. Are there any other considerations for adding coroutines to the main package vs having it in a separate package?