Config

public struct Config: CustomStringConvertible

The service Config is used to disambigute which concrete service should be used if multiple are available for a given protocol

config.prefer(RedisCache.self, for: Cache.self)

Service Config can also be used to set concrete service requirements to ensure a specific concrete services are being used. This can be helpful if you want to ensure non-dev dependencies are being used in production.

config.require(ProductionLogger.self, for: Logger.self)
  • See CustomStringConvertible

    Declaration

    Swift

    public var description: String
  • Creates an empty Config.

    Declaration

    Swift

    public init()
  • Use this method to disambiguate multiple available service implementations for a given interface.

    config.prefer(RedisCache.self, for: Cache.self)
    

    Declaration

    Swift

    public mutating func prefer(_ type: Any.Type, for interface: Any.Type)

    Parameters

    type

    Concrete service type to prefer. This should not be a protocol.

    interface

    The interface to prefer this concrete service for. This must be a protocol that the service conforms to.

  • Use this method to require a given implementation for an interface.

    config.require(ProductionLogger.self, for: Logger.self)
    

    Declaration

    Swift

    public mutating func require(_ type: Any.Type, for interface: Any.Type )

    Parameters

    type

    Concrete service type to require. This should not be a protocol.

    interface

    The interface to require this concrete service for. This must be a protocol that the service conforms to.