Update RiotSwiftUI symbols to triple slash documentation style with function annotations.

This commit is contained in:
David Langley
2021-09-13 11:36:33 +01:00
parent 886bb98eb1
commit 3d65fbd48f
39 changed files with 184 additions and 240 deletions
@@ -17,10 +17,10 @@
import Foundation
import SwiftUI
/**
An Environment Key for retrieving runtime dependencies to be injected into `ObservableObjects`
that are owned by a View (i.e. `@StateObject`'s, such as ViewModels owned by the View).
*/
/// An Environment Key for retrieving runtime dependencies.
///
/// Dependencies are to be injected into `ObservableObjects`
/// that are owned by a View (i.e. `@StateObject`'s, such as ViewModels owned by the View).
private struct DependencyContainerKey: EnvironmentKey {
static let defaultValue = DependencyContainer()
}
@@ -36,12 +36,13 @@ extension EnvironmentValues {
@available(iOS 14.0, *)
extension View {
/**
A modifier for adding a dependency to the SwiftUI view hierarchy's dependency container.
Important: When adding a dependency to cast it to the type in which it will be injected.
So if adding `MockDependency` but type at injection is `Dependency` remember to cast
to `Dependency` first.
*/
/// A modifier for adding a dependency to the SwiftUI view hierarchy's dependency container.
///
/// Important: When adding a dependency to cast it to the type in which it will be injected.
/// So if adding `MockDependency` but type at injection is `Dependency` remember to cast
/// to `Dependency` first.
/// - Parameter dependency: The dependency to add.
/// - Returns: The wrapped view that now includes the dependency.
func addDependency<T>(_ dependency: T) -> some View {
transformEnvironment(\.dependencies) { container in
container.register(dependency: dependency)