Skip to content

Instantly share code, notes, and snippets.

@edelabar
Created January 27, 2024 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edelabar/b07311be9bb9d024925843753101887b to your computer and use it in GitHub Desktop.
Save edelabar/b07311be9bb9d024925843753101887b to your computer and use it in GitHub Desktop.
struct MyView: View {
@State var dep1 = ...
@State var dep2 = ...
@State var cachedProperty = ...
var body: some View {
SomeView()
.task(id: "\(dep1)-\(dep2)") {
// Do expensive calculations...
cachedProperty = ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment