Skip to content

Instantly share code, notes, and snippets.

@eilonkr
Created November 29, 2020 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eilonkr/1579d96f3ea0e67e2e1e1e6112ed287e to your computer and use it in GitHub Desktop.
Save eilonkr/1579d96f3ea0e67e2e1e1e6112ed287e to your computer and use it in GitHub Desktop.
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