Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
masimfacebook2 opened this issue Aug 25, 2022 · 1 comment
Open

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

masimfacebook2 opened this issue Aug 25, 2022 · 1 comment

Comments

@masimfacebook2
Copy link

masimfacebook2 commented Aug 25, 2022

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()
    }
}
@kramlex
Copy link
Contributor

kramlex commented Aug 25, 2022

@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

@Alex009 Alex009 transferred this issue from icerockdev/moko-fields Feb 10, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants