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

rkeazor

03/05/2024, 3:44 PM
Coroutine actors are marked obsolete. Does that mean we should not use them in a prod codebase?
y

Yannik Fuhrmeister

03/05/2024, 3:52 PM
The docs for ObsoleteCoroutinesApi says:
Marks declarations that are obsolete in coroutines API, which means that the design of the corresponding declarations has serious known flaws and they will be redesigned in the future. Roughly speaking, these declarations will be deprecated in the future but there is no replacement for them yet, so they cannot be deprecated right away.
For me that would mean you probably want to replace that with something else soon.
c

Casey Brooks

03/05/2024, 4:08 PM
The Actor API has been deprecated for a very long time. The original intention was that a new Actor API would be developed to replace it, but that has been on hold for a long time and there’s no guarantee that it will ever be continued. So the current Actor APIs aren’t likely to be removed any time soon since there’s no replacement, but there also won’t be any support for them should you find any issues with it. It is also only available for JVM targets so it cannot be used in multiplatform projects. For those reasons, you probably shouldn’t adopt them for a new project, but there’s also not an immediate need to replace them in projects that have already adopted them. If you want to use that exact API, you might want to consider copying the sources into your project so you can maintain and extend it yourself (it’s just a couple small files). Alternatively, there are other Actor libraries or different concurrency patterns which might serve your needs better, such as kactor which was shared here recently, or Ballast for an MVI model of programming
3 Views