Created
May 16, 2023 18:14
-
-
Save braker1nine/a687fbb13a03edc1c483a1c15b739199 to your computer and use it in GitHub Desktop.
ReactiveSwift Bindings
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
extension MutablePropertyProtocol { | |
var binding: Binding<Value> { | |
var binding: Binding<Value> = .init { | |
self.value | |
} set: { newValue in | |
self.value = newValue | |
} | |
self.signal.observeValues { value in | |
binding.update() | |
} | |
return binding | |
} | |
} | |
extension PropertyProtocol { | |
var binding: Binding<Value> { | |
var binding: Binding<Value> = .init { | |
self.value | |
} set: { _ in } | |
self.signal.observeValues { value in | |
binding.update() | |
} | |
return binding | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment