Last active
November 20, 2020 04:18
-
-
Save brunomunizaf/06ef5fac72eebf5470cfdcf7e26466c4 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
| 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