Merge pull request #107 from SDWebImage/add_data_observable

Add the support for image data observable on ImageManager
This commit is contained in:
DreamPiggy 2020-04-30 17:56:27 +08:00 committed by GitHub
commit 8a347dc4dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,8 @@ import SDWebImage
public final class ImageManager : ObservableObject {
/// loaded image, note when progressive loading, this will published multiple times with different partial image
@Published public var image: PlatformImage?
/// loaded image data, may be nil if hit from memory cache. This will only published once even on incremental image loading
@Published public var imageData: Data?
/// loading error, you can grab the error code and reason listed in `SDWebImageErrorDomain`, to provide a user interface about the error reason
@Published public var error: Error?
/// whether network is loading or cache is querying, should only be used for indicator binding
@ -86,6 +88,7 @@ public final class ImageManager : ObservableObject {
self.error = error
self.isIncremental = !finished
if finished {
self.imageData = data
self.isLoading = false
self.progress = 1
if let image = image {