WeakLazyInjected

@propertyWrapper
public struct WeakLazyInjected<Service> where Service : AnyObject

Injects and resolves an optional service when accessed for the first time and deallocates it when there is no strong reference left to it.

  • A wrapped value.

    Declaration

    Swift

    public var wrappedValue: Service? { mutating get set }
  • Initializes a new instance of a service lazily.

    Declaration

    Swift

    public init(
        resolver: Resolver = .main,
        name: String? = nil
    )

    Parameters

    resolver

    An instance of Resolver. Defaults to main.

    name

    The name of a service. Defaults to nil.