Skip to content

Instantly share code, notes, and snippets.

@theangelperalta
Created September 6, 2018 15:23
Show Gist options
  • Save theangelperalta/b5b69d1292628014795ba4a312143c4e to your computer and use it in GitHub Desktop.
Save theangelperalta/b5b69d1292628014795ba4a312143c4e to your computer and use it in GitHub Desktop.
React Swift Wrapper Class
import Foundation
class Box<T> {
typealias Listener = (T) -> Void
var listener: Listener?
var value: T {
didSet {
listener?(value)
}
}
init(_ value: T) {
self.value = value
}
func bind(listener: Listener?) {
self.listener = listener
listener?(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment