nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the propose of `inspect` on RootViewApparence?

amadeu01 opened this issue · comments

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

.onReceive(inspection) { callback in
callback(AnyView(self.body(content: content)))
}

I was checking ce82dfe 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 ?

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).