Hi! I want to create an immutable object in kotlin...
# multiplatform
r
Hi! I want to create an immutable object in kotlin multiplatform (ios/android) so it could be shared between threads in swift. can anyone help me? I tried to add
@SharedImmutable
to properties in a class but got this error:
SharedImmutable is applicable only for top level declarations
. Also tried to run
.freeze()
but this function is not available. what am I missing?
m
Check out this touchlab library. It's excellent for concurrency. They have multiplatform methods for .freeze() and atomics: https://github.com/touchlab/Stately
r
Thanks! I'll try that