Created
May 7, 2020 08:04
-
-
Save anupamchugh/182698f30f06d6b9a62956983cb5c3d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Anything<Wrapper : UIView>: UIViewRepresentable { | |
typealias Updater = (Wrapper, Context) -> Void | |
var makeView: () -> Wrapper | |
var update: (Wrapper, Context) -> Void | |
init(_ makeView: @escaping @autoclosure () -> Wrapper, | |
updater update: @escaping (Wrapper) -> Void) { | |
self.makeView = makeView | |
self.update = { view, _ in update(view) } | |
} | |
func makeUIView(context: Context) -> Wrapper { | |
makeView() | |
} | |
func updateUIView(_ view: Wrapper, context: Context) { | |
update(view, context) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment