Re:Data in SwiftUI, Part 2: Views as a Function of Data
by sleepinseattle on Friday February 14, 2020 @09:27AM
(#22326790)
What is this if not an event?
Button(action: { self.isPlaying.toggle() }
They just happen to be handling it entirely within their view component instead of making it a function on some controller/ViewModel/whatever object that then goes and updates the bool. Each framework then has its own code gen or library or runtime magic that makes that bool change get reflected in other views.
The point of reactive UI is to not deal with events that affect data that affect presentation. Instead, you construct "presentation" every time the data changes, and the framework makes sure to reflect that in an optimal way.