From d7b3d15a2c0721f170ab4ba586943bb5a2c879a5 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 10 Apr 2024 22:18:06 -0700 Subject: [PATCH] Add async method. --- Core/Sources/Core/RSImage.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/Sources/Core/RSImage.swift b/Core/Sources/Core/RSImage.swift index 6549f02a1..7e312031b 100644 --- a/Core/Sources/Core/RSImage.swift +++ b/Core/Sources/Core/RSImage.swift @@ -91,6 +91,14 @@ public extension RSImage { #endif } + static func image(with data: Data) async -> RSImage? { + + let task = Task.detached { () -> RSImage? in + RSImage(data: data) + } + return await task.value + } + /// Asynchronously initializes an image from data. /// /// - Parameters: