Closed periva101 closed 1 year ago
@Alex009 you are fantastic, please keep supporting those libraries, kmm is coming beta soon, and your libraries will be core for the team, keep going
@Alex009
How to observe a CFlow in Moko viewmodel, directly from iOS side inside the Swift UI View ?
val movies: CFlow<MoviesList> get() = _movies.receiveAsFlow().cFlow() // in moko viewmodel
Want to observe in iOS Swift UI view, something like...
HStack {
ForEach(viewmodel.movies.results, id : 100) { movie in
Text(movie.title)
}
}
Is that possible ?
@RageshAntony here post about it - https://medium.com/p/8158e98c091d
@RageshAntony here post about it - https://medium.com/p/8158e98c091d
@Alex009
Thanks,
But I already followed the tutorial. But my problem is with CStateFlow is, I am not getting the Types of the objects in iOS
For example , a snippet from a Viewmodel
private val _cgeneres: MutableStateFlow<GenreList?> = MutableStateFlow(null)
val cgeneres: CStateFlow<GenreList?> = _cgeneres.cStateFlow() // not working
private val _isLoading: MutableStateFlow<Boolean> = MutableStateFlow(false)
val isLoading: CStateFlow<Boolean> = _isLoading.cStateFlow()
.....
@Serializable
data class GenreList(
var genres: ArrayList<Genres> = arrayListOf()
)
When I am trying to access the isLoading
, I am able to get the Data type as Bool
But,Now the problem is, when I am trying to access the cgeneres
, I am unable to get the Data type . It showing some <<error type>>
and I am getting this error : Type of expression is ambiguous without more context
Why is this ?
Swift able to infer the type of a primitive type such as bool but not a data class GenreList. Why ?
I need to manually subscribe to it to get the data. But I need to use them directly like a state variable like that isLoading
boolean variable ?
Please help me!
val state: CStateFlow<BookingUiState> get() = _state.cStateFlow()
how to collect this state in ios, also I want to bind the value to a function call that will fill tableIVew