-
-
Save jasdev/ca7b06625bfcff697d6e9f77cc774d0a to your computer and use it in GitHub Desktop.
Implemented Binding.map.
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
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