title: Memoization in SwiftUI?
body: <p>I come from React where I use <code>useMemo</code> to make sure some computation isn't executed too often. How would I do something like that in SwiftUI?</p>
  
  <p>Consider this example:</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct MyView: View {
      var records: [Record]
  
      var body: some View {
          Text("expensive summary: \(self.expensiveSummary)")
      }
  
      var expensiveSummary: String {
          // based on records, return string
          // containing a summary of records
  
          return ""
      }
  }
  </code></pre>
  
  <p>Is there any way to make sure my <code>expensiveSummary</code> is only called when my array of Records changed?</p>