From aa5044bdd3497394a225460b91d1f14f802019cb Mon Sep 17 00:00:00 2001 From: Vatsal Manot Date: Mon, 7 Oct 2024 16:09:16 +0530 Subject: [PATCH] Update package --- .../Core/withTaskDependencies.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sources/SwiftDI/Intramodular/Core/withTaskDependencies.swift b/Sources/SwiftDI/Intramodular/Core/withTaskDependencies.swift index 3309507..1f33705 100644 --- a/Sources/SwiftDI/Intramodular/Core/withTaskDependencies.swift +++ b/Sources/SwiftDI/Intramodular/Core/withTaskDependencies.swift @@ -80,6 +80,28 @@ public func withTaskDependencies( ) async rethrows -> Result { try await withTaskDependencies({ _ in }, operation: operation) } +#elseif canImport(Translation) +@_transparent +@discardableResult +public func withDependency( + _ dependencyKey: WritableKeyPath, + _ dependency: Dependency, + operation: () async throws -> Result +) async rethrows -> Result { + try await withTaskDependencies { + $0[dependencyKey] = dependency + } operation: { + try await operation() + } +} + +@_transparent +@discardableResult +public func withTaskDependencies( + operation: () async throws -> Result +) async rethrows -> Result { + try await withTaskDependencies({ _ in }, operation: operation) +} #else @_transparent @_unsafeInheritExecutor