I think the propertyWrapper capability should extend to the general variables, like parameters in function.
For example, currently we should write:
func backgroundAndBorder(isSelected: Binding<Bool>) -> some View {
self
.background( isSelected.wrappedValue ? Color.white : Color.black).onTapGesture { isSelected.wrappedValue.toggle() })
.border(Color.primary)
}
but if we extend the propertyWrapper capability to variables and parameters
we could write:
func backgroundAndBorder(@Binding isSelected: Bool) -> some View {
self
.background( isSelected ? Color.white : Color.black).onTapGesture { isSelected.toggle() })
.border(Color.primary)
}
Also it could use for value transformation
we may write:
let intValue = 1234 // Int
let stringValue = "1234" // String
@StringIntWrapper let wrapper = stringValue // StringIntWrapper, pass stringValue into the new StringIntWrapper as its wrapped value
$wrapper == intValue // true, using the projected value of StringIntWrapper
wrapper == stringValue // true, using the wrapped value of StringIntWrapper
PropertyWrapper could be modeled as a general value transfer mechanism.