Skip to content

Commit 8a347dc

Browse files
authored
Merge pull request #107 from SDWebImage/add_data_observable
Add the support for image data observable on ImageManager
2 parents 82ae39a + 2341575 commit 8a347dc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

SDWebImageSwiftUI/Classes/ImageManager.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import SDWebImage
1515
public final class ImageManager : ObservableObject {
1616
/// loaded image, note when progressive loading, this will published multiple times with different partial image
1717
@Published public var image: PlatformImage?
18+
/// loaded image data, may be nil if hit from memory cache. This will only published once even on incremental image loading
19+
@Published public var imageData: Data?
1820
/// loading error, you can grab the error code and reason listed in `SDWebImageErrorDomain`, to provide a user interface about the error reason
1921
@Published public var error: Error?
2022
/// whether network is loading or cache is querying, should only be used for indicator binding
@@ -86,6 +88,7 @@ public final class ImageManager : ObservableObject {
8688
self.error = error
8789
self.isIncremental = !finished
8890
if finished {
91+
self.imageData = data
8992
self.isLoading = false
9093
self.progress = 1
9194
if let image = image {

0 commit comments

Comments
 (0)