Răsfoiți Sursa

Fix for doc and align to original func signature

onevcat 4 ani în urmă
părinte
comite
34723322e0
2 a modificat fișierele cu 31 adăugiri și 1 ștergeri
  1. 19 0
      Sources/General/KF.swift
  2. 12 1
      Sources/SwiftUI/KFImage.swift

+ 19 - 0
Sources/General/KF.swift

@@ -386,6 +386,25 @@ extension KF.Builder {
     }
     }
 }
 }
 
 
+// MARK: - Deprecated
+extension KF.Builder {
+    /// Starts the loading process of `self` immediately.
+    ///
+    /// By default, a `KFImage` will not load its source until the `onAppear` is called. This is a lazily loading
+    /// behavior and provides better performance. However, when you refresh the view, the lazy loading also causes a
+    /// flickering since the loading does not happen immediately. Call this method if you want to start the load at once
+    /// could help avoiding the flickering, with some performance trade-off.
+    ///
+    /// - Deprecated: This is not necessary anymore since `@StateObject` is used for holding the image data.
+    /// It does nothing now and please just remove it.
+    ///
+    /// - Returns: The `Self` value with changes applied.
+    @available(*, deprecated, message: "This is not necessary anymore since `@StateObject` is used. It does nothing now and please just remove it.")
+    public func loadImmediately(_ start: Bool = true) -> Self {
+        return self
+    }
+}
+
 // MARK: - Redirect Handler
 // MARK: - Redirect Handler
 extension KF {
 extension KF {
 
 

+ 12 - 1
Sources/SwiftUI/KFImage.swift

@@ -66,8 +66,19 @@ extension KFImage {
         configure { $0.antialiased(isAntialiased) }
         configure { $0.antialiased(isAntialiased) }
     }
     }
     
     
+    /// Starts the loading process of `self` immediately.
+    ///
+    /// By default, a `KFImage` will not load its source until the `onAppear` is called. This is a lazily loading
+    /// behavior and provides better performance. However, when you refresh the view, the lazy loading also causes a
+    /// flickering since the loading does not happen immediately. Call this method if you want to start the load at once
+    /// could help avoiding the flickering, with some performance trade-off.
+    ///
+    /// - Deprecated: This is not necessary anymore since `@StateObject` is used for holding the image data.
+    /// It does nothing now and please just remove it.
+    ///
+    /// - Returns: The `Self` value with changes applied.
     @available(*, deprecated, message: "This is not necessary anymore since `@StateObject` is used. It does nothing now and please just remove it.")
     @available(*, deprecated, message: "This is not necessary anymore since `@StateObject` is used. It does nothing now and please just remove it.")
-    public func loadImmediately() -> KFImage {
+    public func loadImmediately(_ start: Bool = true) -> KFImage {
         return self
         return self
     }
     }
 }
 }