From d7fbe2f6261fd0799163fe4333d3ef62e77afb82 Mon Sep 17 00:00:00 2001 From: sboko Date: Fri, 9 Oct 2026 08:02:07 +0300 Subject: [PATCH] Declare explicit objectWillChange publishers - ImageManager and IndicatorStatus get a stored ObservableObjectPublisher - the synthesized getter scans a global weak table on every send(), O(N) per image event --- SDWebImageSwiftUI/Classes/ImageManager.swift | 3 +++ SDWebImageSwiftUI/Classes/Indicator/Indicator.swift | 3 +++ 2 files changed, 6 insertions(+) diff --git a/SDWebImageSwiftUI/Classes/ImageManager.swift b/SDWebImageSwiftUI/Classes/ImageManager.swift index 045bfa37..e081dd20 100644 --- a/SDWebImageSwiftUI/Classes/ImageManager.swift +++ b/SDWebImageSwiftUI/Classes/ImageManager.swift @@ -14,6 +14,9 @@ import SDWebImage /// You can use `@ObservedObject` to associate each instance of manager to your View type, which update your view's body from SwiftUI framework when image was loaded. @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) public final class ImageManager : ObservableObject { + /// Explicit publisher: the synthesized one looks itself up in a global table on every access + public let objectWillChange = ObservableObjectPublisher() + /// loaded image, note when progressive loading, this will published multiple times with different partial image public var image: PlatformImage? { didSet { diff --git a/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift b/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift index bf6cc6b3..8ced678b 100644 --- a/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift +++ b/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift @@ -27,6 +27,9 @@ public struct Indicator where T : View { /// A observable model to report indicator loading status @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) public class IndicatorStatus : ObservableObject { + /// Explicit publisher: the synthesized one looks itself up in a global table on every access + public let objectWillChange = ObservableObjectPublisher() + /// whether indicator is loading or not var isLoading: Bool = false { didSet {