feat: Initial view controller dependency and snapshot tests.
This commit is contained in:
31
Sources/ViewController/ViewController.swift
Normal file
31
Sources/ViewController/ViewController.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user