Browse Source

load data on .userInitiated queue

Rob Jonson 4 years ago
parent
commit
ee8b8bd98b
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Sources/General/ImageSource/ImageDataProvider.swift

+ 4 - 2
Sources/General/ImageSource/ImageDataProvider.swift

@@ -89,8 +89,10 @@ public struct LocalFileImageDataProvider: ImageDataProvider {
     /// The key used in cache.
     /// The key used in cache.
     public var cacheKey: String
     public var cacheKey: String
 
 
-    public func data(handler: (Result<Data, Error>) -> Void) {
-        handler(Result(catching: { try Data(contentsOf: fileURL) }))
+    public func data(handler:@escaping (Result<Data, Error>) -> Void) {
+        DispatchQueue.global(qos: .userInitiated).async {
+            handler(Result(catching: { try Data(contentsOf: fileURL) }))
+        }
     }
     }
 
 
     /// The URL of the local file on the disk.
     /// The URL of the local file on the disk.