Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanot committed Oct 7, 2024
1 parent 05704dd commit aa5044b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sources/SwiftDI/Intramodular/Core/withTaskDependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ public func withTaskDependencies<Result>(
) async rethrows -> Result {
try await withTaskDependencies({ _ in }, operation: operation)
}
#elseif canImport(Translation)
@_transparent
@discardableResult
public func withDependency<Dependency, Result>(
_ dependencyKey: WritableKeyPath<TaskDependencyValues, Dependency>,
_ dependency: Dependency,
operation: () async throws -> Result
) async rethrows -> Result {
try await withTaskDependencies {
$0[dependencyKey] = dependency
} operation: {
try await operation()
}
}

@_transparent
@discardableResult
public func withTaskDependencies<Result>(
operation: () async throws -> Result
) async rethrows -> Result {
try await withTaskDependencies({ _ in }, operation: operation)
}
#else
@_transparent
@_unsafeInheritExecutor
Expand Down

0 comments on commit aa5044b

Please sign in to comment.