Skip to content

Instantly share code, notes, and snippets.

@lawreyios
Created May 10, 2020 07:46
Show Gist options
  • Save lawreyios/ee5c05cea70d6ded9d7bdc827d9cbbfc to your computer and use it in GitHub Desktop.
Save lawreyios/ee5c05cea70d6ded9d7bdc827d9cbbfc to your computer and use it in GitHub Desktop.
extension Binding {
func onChange(_ handler: @escaping (Value) -> Void) -> Binding<Value> {
return Binding(
get: { self.wrappedValue },
set: { selection in
self.wrappedValue = selection
handler(selection)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment