https://kotlinlang.org logo
Title
d

diego-gomez-olvera

05/03/2023, 9:54 AM
Is there a recommended thread safe data structure to be used when you want to have a set of listeners that are called for certain actions, something that in JVM could be solved with
CopyOnWriteArraySet
?
private val actionListeners: MutableCollection<ActionListener> = CopyOnWriteArraySet()
in practice I need it for JVM/Android and iOS
maybe the KMP alternative would be to use a
Channel
that emits
Action
instead of a
ActionListener
or a
SharedFlow
p

Pablichjenkov

05/03/2023, 12:56 PM
I would say a SharedFlow/StateFlow yes