I have an ObservableObject
GlobalOO
with a @Published
value.
In any view, I can observe changes with
.onReceive(globalOO.$value) { newValue in
...
}
Now I only want to receive those changes according to a condition in the view
@State private var isActive = false
.onReceive(globalOO.$value.drop(while: { _ in isActive == false })) { newValue in
...
}
This view modifier works but seems "weird". Is there any possibility to create a view modifier that does exactly the same but is more "compact"? Thank you.
Try this!