Files
vapor-po/Sources/ViewController/ViewController.swift

32 lines
817 B
Swift

import Dependencies
import DependenciesMacros
import Elementary
import SharedModels
public extension DependencyValues {
var viewController: ViewController {
get { self[ViewController.self] }
set { self[ViewController.self] = newValue }
}
}
@DependencyClient
public struct ViewController: Sendable {
public typealias AuthenticateHandler = @Sendable (User) -> Void
public var view: @Sendable (ViewRoute, Bool, @escaping AuthenticateHandler) async throws -> (any HTML)?
@Sendable
public func view(
for route: ViewRoute,
isHtmxRequest: Bool,
authenticate: @escaping AuthenticateHandler
) async throws -> (any HTML)? {
try await view(route, isHtmxRequest, authenticate)
}
}
extension ViewController: TestDependencyKey {
public static let testValue: ViewController = Self()
}