Created
November 29, 2020 19:27
-
-
Save eilonkr/1579d96f3ea0e67e2e1e1e6112ed287e to your computer and use it in GitHub Desktop.
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
class Binding<T> { | |
typealias Handler = (T) -> Void | |
public var value: T { | |
didSet { | |
handler?(value) | |
} | |
} | |
private var handler: Handler? | |
public init(_ value: T) { | |
self.value = value | |
} | |
public func bind(_ handler: Handler?) { | |
handler?(value) | |
self.handler = handler | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment