Created
December 20, 2020 16:04
-
-
Save bigMOTOR/80fa4a0753075296f6f44454189795a1 to your computer and use it in GitHub Desktop.
2020-12-20_Article_SwiftUInCleanArchitecture_3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ModelledView: View { | |
associatedtype ViewModel: ObservableObject | |
var viewModel: ViewModel { get } | |
init(model: ViewModel) | |
} | |
struct ModelledViewFactory<T: ModelledView> { | |
@Environment(\.diContainer) private var diContainer: DIContainer | |
func build(_ builder: (DIContainer)->T.ViewModel) -> T { | |
let viewModel = builder(diContainer) | |
return T(model: viewModel) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment