nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
MIT License
5.56k stars 671 forks source link

What is the propose of `inspect` on RootViewApparence? #55

Closed amadeu01 closed 2 years ago

amadeu01 commented 3 years ago

When and why inspection = PassthroughSubject<((AnyView) -> Void), Never>() is used on RootViewApparence ?

https://github.com/nalexn/clean-architecture-swiftui/blob/7ef2ab4963725507b157c0ed553db57e68240717/CountriesSwiftUI/UI/RootViewModifier.swift#L24-L26

I was checking https://github.com/nalexn/clean-architecture-swiftui/commit/ce82dfe715bb596757581c2af37e46eb32ff8dc2 however I am not sure if that was added only due to tests.

Another thing that kept me wondering what is the utility of that property is that you have used ViewInspector on other parts of the project. Wouldn't be the case of using ViewInspector for testing the RootViewApparence as well ?

nalexn commented 3 years ago

Hey @amadeu01 sorry for the late response. Correct, that thing is used purely in tests by the ViewInspector, and this is a necessary workaround to make RootViewApparence testable, since that modifier is using @State (more info about it in the ViewInspector guide).