WIP: Attempt at breaking out some logic / middleware between database and view layer, to remove some code from the view controller. Not complete, maybe revert.
This commit is contained in:
35
Sources/ProjectClient/Interface.swift
Normal file
35
Sources/ProjectClient/Interface.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
import Dependencies
|
||||
import DependenciesMacros
|
||||
import ManualDCore
|
||||
|
||||
extension DependencyValues {
|
||||
public var projectClient: ProjectClient {
|
||||
get { self[ProjectClient.self] }
|
||||
set { self[ProjectClient.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
@DependencyClient
|
||||
public struct ProjectClient: Sendable {
|
||||
public var calculateDuctSizes: @Sendable (Project.ID) async throws -> ProjectResponse
|
||||
}
|
||||
|
||||
extension ProjectClient: TestDependencyKey {
|
||||
public static let testValue = Self()
|
||||
}
|
||||
|
||||
extension ProjectClient {
|
||||
|
||||
public struct ProjectResponse: Codable, Equatable, Sendable {
|
||||
public let rooms: [DuctSizing.RoomContainer]
|
||||
public let trunks: [DuctSizing.TrunkContainer]
|
||||
|
||||
public init(
|
||||
rooms: [DuctSizing.RoomContainer],
|
||||
trunks: [DuctSizing.TrunkContainer]
|
||||
) {
|
||||
self.rooms = rooms
|
||||
self.trunks = trunks
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user