Provider

public struct Provider<K, V> : CustomDebugStringConvertible where K : Hashable

Adds type information to a ProvidableKey.

  • Type of Providables that will be associated with Provider.key.

    Declaration

    Swift

    public typealias Value = V
  • Key

    Type of ProvidableKeys that shall be represented.

    Declaration

    Swift

    public typealias Key = K
  • key

    The represented key of the Provider.

    Declaration

    Swift

    public let key: K
  • Initializes a generic Provider representing the given ProviderKey.

    Declaration

    Swift

    public init(for key: K)

    Parameters

    key

    The represented ProviderKey.

  • Declaration

    Swift

    public var debugDescription: String { get }
  • Automatically generates Provider#key from the caller’s function and the detected type.

    Declaration

    Swift

    public static func derive<V: Providable, K: ProvidableKey & ExpressibleByStringLiteral>(
      function: String = #function
    ) -> Provider<K, V> where K.StringLiteralType == String

    Parameters

    function

    The function where .derive() will be called from.

    Return Value

    A new Provider with a String as ProvidableKey, containing type information and the caller’s function.