Created
December 5, 2022 17:23
-
-
Save hscheuerle/fa5bd7b353169cf3aad42d0becef4267 to your computer and use it in GitHub Desktop.
Binding on change extension
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
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