Use the @Published instead of hard-written protocol implementation

This commit is contained in:
DreamPiggy 2019-10-04 16:28:50 +08:00
parent b7f504c3e6
commit f1d83c1ffc
1 changed files with 1 additions and 9 deletions

View File

@ -7,22 +7,14 @@
*/ */
import SwiftUI import SwiftUI
import Combine
import SDWebImage import SDWebImage
class ImageManager : ObservableObject { class ImageManager : ObservableObject {
@Published var image: PlatformImage?
var objectWillChange = PassthroughSubject<ImageManager, Never>()
var manager = SDWebImageManager.shared var manager = SDWebImageManager.shared
weak var currentOperation: SDWebImageOperation? = nil weak var currentOperation: SDWebImageOperation? = nil
var image: PlatformImage? {
willSet {
objectWillChange.send(self)
}
}
var url: URL? var url: URL?
var options: SDWebImageOptions var options: SDWebImageOptions
var context: [SDWebImageContextOption : Any]? var context: [SDWebImageContextOption : Any]?