Last active
July 5, 2016 16:30
-
-
Save andersio/af06266dc561002122133058096342d7 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
| import Result | |
| import ReactiveCocoa | |
| import Foundation | |
| /*: | |
| ## Sandbox | |
| A place where you can build your sand castles 🏖. | |
| */ | |
| import XCPlayground | |
| XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
| class Token: NSObject { | |
| func receive() { | |
| print("cleanup") | |
| } | |
| } | |
| var token: Token? = Token() | |
| token?.rac_willDeallocSignal() | |
| .subscribeCompleted { [weak token = token!] in | |
| print("\(token == nil)") | |
| NSNotificationCenter | |
| .defaultCenter() | |
| .removeObserver(token!, | |
| name: "RACReceive", | |
| object: nil) | |
| } | |
| NSNotificationCenter | |
| .defaultCenter() | |
| .addObserver(token!, | |
| selector: #selector(Token.receive), | |
| name: "RACReceive", | |
| object: nil) | |
| NSNotificationCenter | |
| .defaultCenter() | |
| .postNotificationName("RACReceive", | |
| object: nil, | |
| userInfo: nil) | |
| token = nil | |
| NSNotificationCenter | |
| .defaultCenter() | |
| .postNotificationName("RACReceive", | |
| object: nil, | |
| userInfo: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment