Hey everyone. How are you guys exposing ViewState in iOS? Normally, in pure android/kotlin I would so something to the likes of this:
Copy code
sealed class ViewState<T> {
object Loading<T> : ViewState()
class Success<T>(val data: T) : ViewState()
class Failure<T>(val error: Throwable): ViewState()
}
But since sealed classes don’t play nice in iOS, I’m wondering what approach you guys are taking?
m
mkrussel
06/23/2022, 1:14 PM
I've just been still doing the sealed classes like I would if it was just an Android project.
It's not as nice to use in Swift as in Kotlin, but is still pretty usable.
There is a gradle plugin from someone that can convert sealed classes to Swift enums. I've not used it so I cannot give any feedback.
https://github.com/icerockdev/moko-kswift
t
timkranen
06/23/2022, 1:15 PM
Thanks! I’ll give it another go. Saw this plugin too, but I couldn’t get this to work for me for some reason. Let me see if I can get it to work out of the box, searching the slack channel already gave me some insights too.