Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created July 20, 2020 01:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Implemented Binding.map.
extension Binding {
func map<Subject>(
get: @escaping (Value) -> Subject,
set: @escaping (inout Value, Subject) -> Void
) -> Binding<Subject> {
.init(
get: { get(self.wrappedValue) },
set: { set(&self.wrappedValue, $0) }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment