What would be idiomatic way to create kotlin objec...
# kotlin-native
k
What would be idiomatic way to create kotlin objects in iOS app (swift code), that could have mutable structures inside it? E.g. object, that have mutable map. Object will be passed multiple times between swift and kotlin, and will be alive for hours during application execution. Immutable objects are not suitable, as we need to modify up to 100K of such objects per second. Mutability needed only from Kotlin code. Now we use separate thread on Swift side, and we have lot of boilerplate code, to ensure, that all kotlin objects are accessed from single thread only. I'm looking into way to simplify it on swift side, and allow pass these specific kotlin objects across entire app.
o
StableRef can be passed freely, but Kotlin side access must be from the same thread/worker. Another option is to use Objective-C objects.
k
Thanks!
@olonho is there any example for what you described? I stil can't figure it out how to make it working? I either got exceptions related to object being frozen, or that I tried to access them from wrong thread.