Skip to content

Instantly share code, notes, and snippets.

@brunomunizaf
Last active November 20, 2020 04:18
Show Gist options
  • Select an option

  • Save brunomunizaf/06ef5fac72eebf5470cfdcf7e26466c4 to your computer and use it in GitHub Desktop.

Select an option

Save brunomunizaf/06ef5fac72eebf5470cfdcf7e26466c4 to your computer and use it in GitHub Desktop.
final class Box<T> {
var listener: ((T) -> Void)?
var value: T {
didSet { listener?(value) }
}
init(_ value: T) {
self.value = value
}
func bind(listener: ((T) -> Void)?) {
self.listener = listener
listener?(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment