Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Created October 29, 2021 18:45
Show Gist options
  • Save mbrandonw/c99ec1c5df864f5e4a4d91604ebff68c to your computer and use it in GitHub Desktop.
Save mbrandonw/c99ec1c5df864f5e4a4d91604ebff68c to your computer and use it in GitHub Desktop.
extension Binding {
func didSet(_ perform: @escaping (Value) -> Void) -> Self {
.init(
get: { self.wrappedValue },
set: { newValue, transaction in
self.transaction(transaction).wrappedValue = newValue
perform(newValue)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment