curioustechizen
12/04/2023, 11:01 AMsealed class Action {
object OnCtaClick : Action()
data class OnClassClick(val classId: Int) : Action()
}
fun processAction(action: Action) {
when(action) {
is OnCtaClick -> {
println("OnCtaClick")
}
is Action.OnClassClick -> {
println("OnClassClick ${action.classId}")
}
}
}
And when I call it from Swift, I cannot take advantage of the onEnum(of:)
facility of SKIE. I still need to call it like this:
processAction(action: Action.OnCtaClick())
processAction(action: Action.OnClassClick(classId: 2))
But I would like to call it like this:
processAction(.onCtaClick)
processAction(.onClassClick(classId: 2))
Filip Dolník
12/04/2023, 11:39 AMcurioustechizen
12/04/2023, 11:50 AMclass BaseViewModel<S, A>
and I don't see a way to define this extension function to work with generics so I'm going to leave it as-is. The effort definitely outweighs the benefit.
Thanks for the recommendation!Filip Dolník
12/04/2023, 11:51 AM