Created
July 4, 2018 08:53
-
-
Save onmyway133/807793516bbc0abff0bcb0e297be26dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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