I have a struct that need to present some view when variable in class changes.
Example:
struct Example: View {
@StateObject var isText = ProviderDelegate()
var body: some View {
Text("here some text")
if(isText.show) {
Bar()
}
}
the providerDelegate:
class Adapter: ObservableObject {
@Published public var show: Bool = false;
func changeShow() {
show.toggle()
}
...
}
when function from other class to changeShow the View is not updation, thus the bar() is not shown.
Why is that?