Skip to content

Instantly share code, notes, and snippets.

Created April 8, 2023 19:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
SDUIComponent Helper
extension SDUIComponent {
private var concreteModel: Any {
switch self {
case .button(let button):
return button
case .row(let row):
return row
case .text(let text):
return text
func viewModel(context: SDUIContext) -> ViewModel? {
if let concreteModel = concreteModel as? ViewModelConvertible {
return concreteModel.viewModel(context: context)
} else {
assertionFailure("This component is not supported")
return nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment