Browse Source

Add docs for loadImmediately

onevcat 5 years ago
parent
commit
ed7a235d4a
1 changed files with 12 additions and 2 deletions
  1. 12 2
      Sources/SwiftUI/KFImage.swift

+ 12 - 2
Sources/SwiftUI/KFImage.swift

@@ -106,8 +106,18 @@ public struct KFImage: View {
             .id(context.binder)
     }
 
-    public func loadImmediately() -> KFImage {
-        context.binder.start()
+    /// Starts the loading process of `self` immediately.
+    ///
+    /// By default, a `KFImage` will not load its source until its `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.
+    ///
+    /// - Returns: The `Self` value with changes applied.
+    public func loadImmediately(_ start: Bool = true) -> KFImage {
+        if start {
+            context.binder.start()
+        }
         return self
     }
 }