Skip to content

Commit 8726479

Browse files
committed
changed factory in async registration to async registration factory
1 parent edd8abb commit 8726479

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/Container/AsyncContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private extension AsyncContainer {
140140
// We use force cast here because we are sure that the type-casting always succeed
141141
// The reason why the `factory` closure returns ``Any`` is that we have to erase the generic type in order to store the registration
142142
// When the registration is created it can be initialized just with a `factory` that returns the matching type
143-
let dependency = try await registration.factory(self, argument) as! Dependency
143+
let dependency = try await registration.asyncRegistrationFactory(self, argument) as! Dependency
144144

145145
switch registration.scope {
146146
case .shared:

Sources/Models/AsyncRegistration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ typealias AsyncRegistrationFactory = @Sendable (any AsyncDependencyResolving, (a
1313
struct AsyncRegistration: Sendable {
1414
let identifier: RegistrationIdentifier
1515
let scope: DependencyScope
16-
let factory: AsyncRegistrationFactory
16+
let asyncRegistrationFactory: AsyncRegistrationFactory
1717

1818
/// Initializer for registrations that don't need any variable argument
1919
init<T: Sendable>(type: T.Type, scope: DependencyScope, factory: @Sendable @escaping (any AsyncDependencyResolving) async -> T) {
2020
self.identifier = RegistrationIdentifier(type: type)
2121
self.scope = scope
22-
self.factory = { resolver, _ in await factory(resolver) }
22+
self.asyncRegistrationFactory = { resolver, _ in await factory(resolver) }
2323
}
2424

2525
/// Initializer for registrations that expect a variable argument passed to the factory closure when the dependency is being resolved
@@ -28,7 +28,7 @@ struct AsyncRegistration: Sendable {
2828

2929
self.identifier = registrationIdentifier
3030
self.scope = scope
31-
self.factory = { resolver, arg in
31+
self.asyncRegistrationFactory = { resolver, arg in
3232
guard let argument = arg as? Argument else {
3333
throw ResolutionError.unmatchingArgumentType(message: "Registration of type \(registrationIdentifier.description) doesn't accept an argument of type \(Argument.self)")
3434
}

0 commit comments

Comments
 (0)