Hi, Is there a way to call `ensureNeverFrozen` fro...
# kotlin-native
j
Hi, Is there a way to call
ensureNeverFrozen
from common code or swift code ? For the moment I only can access concurrent functions like
freeze
and
ensureNeverFrozen
in the iosMain shared code. I have an
InvalidMutabilityException
calling ktor get function but I only call common code and can't use
ensureNeverFrozen
in commin code to debug
n
That’s because
freeze()
and
ensureNeverFrozen()
are K/N only. A common pattern is to create your own expect/actual, which does nothing on K/JVM and K/JS targets and calls the actual
freeze()
on K/N. For ex: Ktor is exposing it’s own
makeShared()=freeze()
and
preventFreeze()=ensureNeverFrozen()
. Also I’m not sure if this K/N only design is something intended from JB
You can check out an example solution from Touchlab’s Stately
j
Thanks I will forward that to my ios dev and 🤞