You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want complete control over the service responsible for managing the state of the view and for fetching the image you could pass an object conforming to the `RemoteImageService` to the related initializer:
61
+
62
+
```swift
63
+
let url =URL(string: "https://images.unsplash.com/photo-1524419986249-348e8fa6ad4a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80")!
64
+
65
+
RemoteImage(type: .url(url), service: yourCustomService, errorView: { error in
66
+
Text(error.localizedDescription)
67
+
}, imageView: { image in
68
+
image
69
+
.resizable()
70
+
.aspectRatio(contentMode: .fit)
71
+
}, loadingView: {
72
+
Text("Loading ...")
73
+
})
74
+
```
75
+
76
+
## Custom `RemoteImageURLDataPublisher`
77
+
78
+
Under the hood by default the `URLSession.shared` is used as the `RemoteImageURLDataPublisher` to fetch the image at the specified URL.
79
+
You can specify a custom publisher through the`remoteImageURLDataPublisher` parameter.
80
+
As an example that's how you could add support for low data mode to the `RemoteImage` view.
81
+
82
+
```swift
83
+
let url =URL(string: "https://images.unsplash.com/photo-1524419986249-348e8fa6ad4a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80")!
The `RemoteImageService` uses a default cache. To use a custom one just conform to the protocol `RemoteImageCache` and set it on the type `RemoteImageService`.
0 commit comments