Created
August 8, 2017 18:50
-
-
Save CollectiveHealth-gists/8daab3214071a1da119a8993578483eb to your computer and use it in GitHub Desktop.
RxSwift Download Image from Url
This file contains 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
URLSession.shared.rx | |
.response(imageURL) | |
// subscribe on main thread | |
.subscribeOn(MainScheduler.sharedInstance) | |
.subscribe(onNext: { [weak self] data in | |
// Update Image | |
self?.imageView.image = UIImage(data: data) | |
}, onError: { | |
// Log error | |
}, onCompleted: { | |
// animate image view alpha | |
UIView.animateWithDuration(0.3) { | |
self.imageView.alpha = 1 | |
} | |
}).addDisposableTo(disposeBag) |
memory leak on lines 10, 12
Thanks a lot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanxxx!