init(_:fileID:filePath:line:column:)

Creates a dependency property to read the specified key path.

Dependency.swift:126
init(_ keyPath: KeyPath<DependencyValues, Value> & Sendable, fileID: StaticString = #fileID, filePath: StaticString = #filePath, line: UInt = #line, column: UInt = #column)

Parameters

keyPath

A key path to a specific resulting value.

Don’t call this initializer directly. Instead, declare a property with the Dependency property wrapper, and provide the key path of the dependency value that the property should reflect:

@Observable
final class FeatureModel {
  @ObservationIgnored
  @Dependency(\.date) var date

  // ...
}