https://kotlinlang.org logo
#coroutines
Title
# coroutines
o

Orhan Tozan

03/25/2020, 4:00 AM
In a multi-module project, should a kotlin module that exposes Flow as its public api, specify its coroutines dependency as
api
instead of
implementation
? Also if so, does this also mean for target dependencies (e.g. commonMain:
api(coroutines-core-common)
and jvmMain:
api(coroutines-core)
)
o

octylFractal

03/25/2020, 5:19 AM
yes to the first question, I don't know if it matters for the second
t

tseisel

03/25/2020, 7:41 AM
Since you're exposing the
Flow
type to other modules, it is wise to also share dependency on coroutines-core, otherwise consumer modules won't be able to resolve
Flow
(unless they also specify coroutines-core as dependency) I haven't tried MPP yet, but I think it also applies. Just declare the correct dependency as
api
for the corresponding platform:
commonMain
-> coroutines-core-common
jvmMain
-> coroutines-core
jsMain
-> coroutines-core-js etc.
o

Orhan Tozan

03/25/2020, 7:43 AM
Allright so api on all targets including common. The thing is, I was doing that, but getting errors that there was some conflicting dependencies or that it couldnt access flow because of module classpath. Replacing the api cascadings with all modules implementing the coroutines dependencies on their own fixed it.
3 Views