there is `actor { }`
# coroutines
v
there is
actor { }
c
that’s only available on JVM. I’m needing some way to have similar functionality in an MPP app. Besides,
actor { }
is deprecated, so I don’t really want to get bought into an API that is not being supported and may be removed
z
Flow and actors are completely unrelated. If you need a full-fledged actor library, even
actor
would be insufficient, but if you just want to serialized concurrent access to mutable state it's really easy to just make an inbox channel and launch a coroutine to read from it and process messages (basically all
actor
does anyway). All the pieces for that should be available for multiplatform, I'm surprised
actor
isn't.
👍 1
c
Yeah, I’m not needing anything too crazy. Basically just need to process a stream of events that do some computation and then update/replace an immutable state object. I was hoping for a higher-level API that using channels directly, but I will give that a shot
z
Sounds like you could also just implement that as a stream transformer with Flow. The flow approach is more push-based, the actor one is more pull-based. Maybe one advantage of the actor approach is that it focuses on ownership of the processor – you explicitly launch a single coroutine to do the processing from a single channel, it’s clear there’s only one of each and what their lifetime is. With a flow approach, something like
events.transform { … }.stateIn(scope)
, fact that there’s a single transformer and inbox is implied by the
stateIn
, but it’s less obvious. Also,
stateIn
doesn’t exist yet 😅
h
actor
will be deprecated in the future yeah? 🤔
b
The current form of actors are not so much deprecated as obsolete, in they are working on a new design for them to support more complex use cases. I would be quite surprised if they break binary compatibility even once the new design is finished and released
h
Got it... I just don't use it because the docs say to do so 😄