24. SwiftUI Lifecycle Event Modifiers
One of the key strengths of SwiftUI is that, through use of features such as views, state properties and observable objects, much of the work required in making sure an app handles lifecycle changes correctly is performed automatically.
It is still often necessary, however, to perform additional actions when certain lifecycle events occur. An app might, for example, need to perform a sequence of actions at the point that a view appears or disappears within a layout. Similarly, an app may need to execute some code each time a value changes, or to detect when a view becomes active or inactive. All of these requirements and more can be met by making use of a set of event modifiers provided by SwiftUI.
Since event modifiers are best understood when seen in action, this chapter will create a project which makes use of the three most commonly used modifiers.