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

Andrea Giuliano

08/25/2020, 7:28 AM
Hi guys, question on the @ExperimentalCoroutinesApi, is that safe to use them in production? I’ve seen a bunch of interesting components marked like that but I’m a bit scared to use them because of the annotation. What do you do in this case?
t

Tim Malseed

08/25/2020, 7:36 AM
ExperimentalCoroutinesApi
Marks declarations that are still experimental in coroutines API, which means that the design of the corresponding declarations has open issues which may (or may not) lead to their changes in the future. Roughly speaking, there is a chance that those declarations will be deprecated in the near future or the semantics of their behavior may change in some way that may break some code.
a

Andrea Giuliano

08/25/2020, 7:36 AM
gotcha, so I guess the answer is no 🙂
t

Tim Malseed

08/25/2020, 7:37 AM
It really depends. It's up to you (or, your company) whether it's worth the risk
I think that these API's are probably reasonably well tested internally (by Jetbrains). Mostly the risk is that the behavior might change, and you'll have to refactor your code to compensate.
t

Tim Malseed

08/25/2020, 7:40 AM
If you're the only one maintaining the code, and it's not mission critical, or you can test it and be pretty confident that it behaves correctly, I don't see why it can't be used in production.
a

Andrea Giuliano

08/25/2020, 7:40 AM
for example here they say: Note: This is an experimental api.** It may be changed in the future updates.
t

Tim Malseed

08/25/2020, 7:40 AM
Yeah, it looks like BroadcastChannel will be deprecated soon, and replaced with StateFlow (and others)
a

Andrea Giuliano

08/25/2020, 7:41 AM
gotcha, so for example if I would like to start a primitive to broadcast messages, should I start with StateFlow?
t

Tim Malseed

08/25/2020, 7:42 AM
It kinda depends what you're trying to do. StateFlow is a specific implementation of BroadcastChannel
TBH, I would just use BroadcastChannel for now
g

gildor

08/25/2020, 7:43 AM
safe to use them in production
On production of the app? why not? It may change? Yes, or will not change, it will not affect you until you update versions of kotlinx.coroutines For library? not really, until you propagate all those experimantal warnings to public API, so users of it would also know that API is experimental It’s very broad set of cases when you say “safe to use on production”, depends what is safe for you and what kind production
☝️ 1
t

Tim Malseed

08/25/2020, 7:43 AM
I'd say StateFlow is marked as experimental as well
a

Andrea Giuliano

08/25/2020, 7:44 AM
👍
g

gildor

08/25/2020, 7:45 AM
I wouldn’t use BroadcastChannel now if your case is covered with StateFlow
but it doesn’t mean that it safe or unsafe for production, just a matter of code evolution
a

Andrea Giuliano

08/25/2020, 7:46 AM
that makes sense, thanks guys
8 Views