Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created June 27, 2019 13:45
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save chriseidhof/d2fcafb53843df343fe07f3c0dac41d5 to your computer and use it in GitHub Desktop.
Save chriseidhof/d2fcafb53843df343fe07f3c0dac41d5 to your computer and use it in GitHub Desktop.
LazyView
struct LazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}
@ahmetws
Copy link

ahmetws commented Nov 21, 2019

Thanks for the code, Chris 👍
Here is the relevant discussion: https://twitter.com/chriseidhof/status/1144242544680849410

@mahmudahsan
Copy link

Thank you very much. It helps a lot!

@ChineseHooper
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment