With CStateFlow , I am not getting the Types of the objects in iOS when accessing from State
RageshAntony opened this issue · comments
I already followed the tutorial https://medium.com/p/8158e98c091d.
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!
For own types you should add extension state as here