feat: Breaking out more dependencies.

This commit is contained in:
2024-12-10 17:08:17 -05:00
parent 87390c4b63
commit 92cd6afa2b
20 changed files with 1408 additions and 691 deletions

View File

@@ -0,0 +1,33 @@
import Dependencies
import DependenciesMacros
import Foundation
import TOMLKit
public extension DependencyValues {
var coders: Coders {
get { self[Coders.self] }
set { self[Coders.self] = newValue }
}
}
@DependencyClient
public struct Coders: Sendable {
public var jsonDecoder: @Sendable () -> JSONDecoder = { .init() }
public var jsonEncoder: @Sendable () -> JSONEncoder = { .init() }
public var tomlDecoder: @Sendable () -> TOMLDecoder = { .init() }
public var tomlEncoder: @Sendable () -> TOMLEncoder = { .init() }
}
extension Coders: DependencyKey {
public static var testValue: Self { Self() }
public static var liveValue: Self {
.init(
jsonDecoder: { JSONDecoder() },
jsonEncoder: { JSONEncoder() },
tomlDecoder: { TOMLDecoder() },
tomlEncoder: { TOMLEncoder() }
)
}
}