moko-mvvm icon indicating copy to clipboard operation
moko-mvvm copied to clipboard

Support for bindText(flow: <CStateFlow<T>) on IOS

Open masimfacebook2 opened this issue 3 years ago • 1 comments

I can't use this function on the IOS side, it gives an error: Instance method 'bindText(flow:)' requires that 'StringDesc' inherit from 'NSString'

Solution: In mmp-library / src I created iosMain and there a file with the extension

import dev.icerock.moko.mvvm.flow.CStateFlow
import dev.icerock.moko.mvvm.flow.binding.bind
import dev.icerock.moko.resources.desc.StringDesc
import platform.UIKit.UILabel

fun UILabel.bindFlow(flow: CStateFlow<StringDesc?>) = bind(flow) {
    if (it != null) {
        this.text = it.localized()
    }
}

masimfacebook2 avatar Aug 25 '22 08:08 masimfacebook2

@masimfacebook2 please create this issue in moko-mvvm. this one will be closed

binding functions is moko-mvvm-flow: https://github.com/icerockdev/moko-mvvm/tree/master/mvvm-flow/src/iosMain/kotlin/dev/icerock/moko/mvvm/flow/binding

kramlex avatar Aug 25 '22 08:08 kramlex