Skip to content

Instantly share code, notes, and snippets.

@hscheuerle
Created December 5, 2022 17:23
Show Gist options
  • Save hscheuerle/fa5bd7b353169cf3aad42d0becef4267 to your computer and use it in GitHub Desktop.
Save hscheuerle/fa5bd7b353169cf3aad42d0becef4267 to your computer and use it in GitHub Desktop.
Binding on change extension
import SwiftUI
extension Binding {
func onChange(_ handler: @escaping () -> Void) -> Binding<Value> {
Binding(
get: { self.wrappedValue },
set: { newValue in
self.wrappedValue = newValue
handler()
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment