Skip to content

Commit 7128a13

Browse files
committed
Update the readme about the success/failure/progress handle
1 parent b1940df commit 7128a13

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ let package = Package(
6363

6464
+ Using `WebImage` to load network image
6565

66-
It supports the placeholder and detail options control for image loading as SDWebImage.
66+
Supports the placeholder and detail options control for image loading as SDWebImage.
67+
68+
Supports the success/failure/progress changes event for custom handling.
6769

6870
Note: Unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation. This `WebImage` using `Image` for internal implementation and supports static image format only.
6971

7072
```swift
7173
var body: some View {
7274
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
75+
.onSuccess(perform: { (image, cacheType) in
76+
// Success
77+
})
7378
.resizable()
7479
.scaledToFit()
7580
.frame(width: 300, height: 300, alignment: .center)
@@ -81,6 +86,9 @@ var body: some View {
8186
```swift
8287
var body: some View {
8388
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
89+
.onFailure(perform: { (error) in
90+
// Error
91+
})
8492
.scaledToFit()
8593
AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
8694
.scaledToFill()

0 commit comments

Comments
 (0)