title: Combine onChange and onAppear events in SwiftUI view?
body: <p>I'm observe a property on a view using the <code>onChange</code> modifier. However, I'd also like the same piece of code to run on the initial value as well because sometimes the data is injected in the initializer or asynchronously loaded later.</p>
  <p>For example, I have a view that gets a model injected. Sometimes this model has data in it to begin with (like previews), or is asynchronously retrieved from the network.</p>
  <pre><code>class MyModel: ObservableObject {
      @Published var counter = 0
  }
  
  struct ContentView: View {
      @ObservedObject var model: MyModel
      
      var body: some View {
          VStack {
              Text(&quot;Counter: \(model.counter)&quot;)
              Button(&quot;Increment&quot;) { model.counter += 1 }
          }
          .onChange(of: model.counter, perform: someLogic)
          .onAppear { someLogic(counter: model.counter) }
      }
      
      private func someLogic(counter: Int) {
          print(&quot;onAppear: \(counter)&quot;)
      }
  }
  </code></pre>
  <p>In both <code>onAppear</code> and <code>onChange</code> cases, I'd like to run <code>someLogic(counter:)</code>. Is there a better way to get this behaviour or combine them?</p>