Anton Afanasev
09/03/2021, 2:16 PM// Multiplatform
class KmmLibrary(private val listener: Listener) {
fun doSomething() {
listener.notifyResult("All good!")
}
interface Listener {
fun notifyResult(result: String)
}
}
// Native
struct ContentView: View {
@State private var message: String = ""
private let kmmLibrary: KmmLibrary
init() {
self.kmmLibrary = KmmLibrary(listener: NativeListener())
}
class NativeListener: Listener {
func notifyResult(result: String) {
print(result)
}
}
}
Does not this code created retain cycle on iOS (Native)?
Should I somehow wrap it with WeakReference using expect/actual mechanism or are there any other common practices?Andrey Chernov
09/03/2021, 4:10 PMAnton Afanasev
09/03/2021, 5:16 PM