Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created July 4, 2018 08:53
Show Gist options
  • Save onmyway133/807793516bbc0abff0bcb0e297be26dc to your computer and use it in GitHub Desktop.
Save onmyway133/807793516bbc0abff0bcb0e297be26dc to your computer and use it in GitHub Desktop.
class Binding<T> {
var value: T {
didSet {
listener?(value)
}
}
private var listener: ((T) -> Void)?
init(value: T) {
self.value = value
}
func bind(_ closure: @escaping (T) -> Void) {
closure(value)
listener = closure
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment