Created
March 28, 2018 16:52
-
-
Save ktanaka117/a30800c162395925cfdb6ec67808d9b2 to your computer and use it in GitHub Desktop.
disposeしたら通信をキャンセルするサンプル #CodePiece
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
let single = Single<Void>.create { singleEvent in | |
let req = Alamofire.request("https://www.google.co.jp/") | |
req.response { response in | |
print("通信完了") | |
} | |
return Disposables.create(with: { | |
print("通信キャンセル") // <- こっちが出た | |
req.cancel() | |
}) | |
} | |
single.subscribe().dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment