-
-
Save AndriiTsok/e49a90f0aa648314b6ba0d35ef42fca0 to your computer and use it in GitHub Desktop.
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
struct TestView: View { | |
@Environment(\.injected) private var injected: DIContainer | |
@State private var product: Loadable<Product> = .notRequested | |
@State private var company: Loadable<Company> = .notRequested | |
var productId: String | |
var body: some View { | |
self.content | |
.onAppear { | |
self.injected.interactors.productInteractor.load(product: self.$product, by: self.productId) | |
} | |
} | |
var content: AnyView { | |
switch self.product { | |
case .notRequested: | |
return AnyView(pageLoading) | |
case .isLoading: | |
return AnyView(pageLoading) | |
case let .loaded(product): | |
return AnyView(page.onAppear { | |
self.injected.interactors.organizationInteractor.load(company: self.$company, by: product.id) | |
}) | |
case let .failed(pageError): | |
return AnyView(page) | |
} | |
} | |
var page: some View { | |
ScrollView { | |
....... SOME Views that bind for both properties .... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment