Hi guys, question on the @ExperimentalCoroutinesAp...
# coroutines
a
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
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
gotcha, so I guess the answer is no 🙂
t
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
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
for example here they say: Note: This is an experimental api.** It may be changed in the future updates.
t
Yeah, it looks like BroadcastChannel will be deprecated soon, and replaced with StateFlow (and others)
a
gotcha, so for example if I would like to start a primitive to broadcast messages, should I start with StateFlow?
t
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
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
I'd say StateFlow is marked as experimental as well
a
👍
g
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
that makes sense, thanks guys