Resolver

public final class Resolver

A dependency injection registry that registers and resolves services.

  • The main Resolver.

    Declaration

    Swift

    public static var main: Resolver
  • The default scope graph.

    Declaration

    Swift

    public static var defaultScope: Scope
  • A boolean value to indicate whether to ensure thread safety while registering and resolving services or not. Defaults to true that means thread-safe. Sometimes, it is better to set it to false in a single-threaded environment or for services that are only going to be used in a single thread such as UI thread for performance reasons.

    Declaration

    Swift

    public var isAtomic: Bool
  • Initializes a new instance of Resolver.

    Declaration

    Swift

    public init(isAtomic: Bool = true)

    Parameters

    isAtomic

    A boolean value to indicate whether to ensure thread safety while registering and resolving services or not. Defaults to true that means thread-safe.

  • Registers a service with one argument.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with two arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with three arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with four arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with five arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with six arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with seven arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with eight arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with nine arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with ten arguments.

    Declaration

    Swift

    @discardableResult
    public static func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service with one argument.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with two arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with three arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with four arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with five arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with six arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with seven arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with eight arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with nine arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Registers a service with ten arguments.

    Declaration

    Swift

    @discardableResult
    public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Resolves a service with one argument registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with two arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with three arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with four arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with five arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with six arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with seven arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with eight arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with nine arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8, _ arg9: Arg9
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    arg9

    The ninth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with ten arguments registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8, _ arg9: Arg9, _ arg10: Arg10
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    arg9

    The ninth argument of a service.

    arg10

    The tenth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with one argument.

    Declaration

    Swift

    public func resolve<Service, Arg1>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with two arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with three arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with four arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with five arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with six arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with seven arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with eight arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with nine arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8, _ arg9: Arg9
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    arg9

    The ninth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service with ten arguments.

    Declaration

    Swift

    public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7,
        _ arg8: Arg8, _ arg9: Arg9, _ arg10: Arg10
    ) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    arg1

    The first argument of a service.

    arg2

    The second argument of a service.

    arg3

    The third argument of a service.

    arg4

    The fourth argument of a service.

    arg5

    The fifth argument of a service.

    arg6

    The sixth argument of a service.

    arg7

    The seventh argument of a service.

    arg8

    The eighth argument of a service.

    arg9

    The ninth argument of a service.

    arg10

    The tenth argument of a service.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Registers a service in the main Resolver.

    Declaration

    Swift

    @discardableResult
    public static func register<Service>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver) -> Service
    ) -> Resolver

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The main Resolver.

  • Registers a service.

    Declaration

    Swift

    @discardableResult
    public func register<Service>(
        _ type: Service.Type = Service.self,
        named name: String? = nil,
        scoped scope: Scope = defaultScope,
        factory: @escaping (Resolver) -> Service
    ) -> Self

    Parameters

    type

    The type of a service. Defaults to the concrete type that is going to be initialized.

    name

    The name of a service. Defaults to nil.

    scope

    The scope of a service. Defaults to defaultScope.

    factory

    A factory method that creates a new instance of a service.

    Return Value

    The current instance of Resolver registering a service.

  • Resets the main Resolver and removes all registered services.

    Declaration

    Swift

    public func reset()
  • Resolves a service registered in the main Resolver.

    Declaration

    Swift

    public static func resolve<Service>(_ type: Service.Type = Service.self, named name: String? = nil) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    Return Value

    An instance of a registered service or nil if it is not registered.

  • Resolves a service.

    Declaration

    Swift

    public func resolve<Service>(_ type: Service.Type = Service.self, named name: String? = nil) -> Service?

    Parameters

    type

    The type of a service. Defaults to the type inferred from the return type.

    name

    The name of a service. Defaults to nil.

    Return Value

    An instance of a registered service or nil if it is not registered.