Update `Binding` Helpers
- Rename `Binding.map` to `Binding.compactMap` - Add `Binding.map` with an updated signature These should now match the naming conventions of similar methods on types.
This commit is contained in:
parent
883ce52011
commit
24c21d4965
|
@ -74,7 +74,14 @@ extension Binding {
|
|||
)
|
||||
}
|
||||
|
||||
func map<T>(extract: @escaping (Value) -> T, embed: @escaping (T) -> Value?) -> Binding<T> {
|
||||
func map<T>(extract: @escaping (Value) -> T, embed: @escaping (T) -> Value) -> Binding<T> {
|
||||
Binding<T>(
|
||||
get: { extract(wrappedValue) },
|
||||
set: { wrappedValue = embed($0) }
|
||||
)
|
||||
}
|
||||
|
||||
func compactMap<T>(extract: @escaping (Value) -> T, embed: @escaping (T) -> Value?) -> Binding<T> {
|
||||
Binding<T>(
|
||||
get: { extract(wrappedValue) },
|
||||
set: {
|
||||
|
|
Loading…
Reference in New Issue