Kotlin Actor support for Multiplatform is not plan...
# coroutines
h
Kotlin Actor support for Multiplatform is not planned. However, I would like to migrate some code to be multi-platform compatible. What is another way I could achieve the same behavior of an actor with multiplatform? Does anyone have some code to show how to do this? I’ve dug through old threads and google searches and shown the only replacement that was shared: https://gist.github.com/handstandsam/0ac44478f5378c079904458b0a013f83
👀 1
s
I’ve used something along the lines of
MutliplatformActor.kt
before, but it depends a bit on the use-case I’d say.
I always think about Akka actors which are quite different from the original Kotlinx actors.
🤔 1
h
I'll have to look into Akka actors. I haven't heard of that before.
s
https://www.lightbend.com/akka-platform They’re really powerful, and can do things such as persist themselves and auto-recover, etc. It’s a framework, but it’s more in spirit with the famous Erlang Actors.
👍 1
How I’ve seen actors in Kotlin it was more of a process that could receive “hot” messages, and it produces another message as output. If you can guarantee that the mapping of incoming to outcoming messages cannot fail, then the actor is also guaranteed to long as long as the
CoroutineScope
it’s run on. So I think in that regard all old
actor
code can be safely replaced by the function linked in your gist.
Although it might be nicer to use
launch
directly inside of
StoreRealActor
rather than build your own
actor
function. The only
actor
really does is install a
event transformer
on a process (
launch
).
This code is as simple as before IMO, but doesn’t rely on
actor
.
👍 1