From c3a971b49ea93ffc3a08b7f3ab74c7cd30141dd2 Mon Sep 17 00:00:00 2001 From: Brendan Szymanski Date: Sun, 14 Jun 2026 16:18:05 -0400 Subject: [PATCH] Add @unchecked Sendable conformance and @Sendable handler to DIContainer --- Sources/LuminateDI/DIContainer.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/LuminateDI/DIContainer.swift b/Sources/LuminateDI/DIContainer.swift index 9698aa3..b2cac93 100644 --- a/Sources/LuminateDI/DIContainer.swift +++ b/Sources/LuminateDI/DIContainer.swift @@ -1,10 +1,10 @@ import Foundation -public final class DIContainer { +public final class DIContainer: @unchecked Sendable { public static let shared = DIContainer() public private(set) var values = InjectionValues() - private var observers: [AnyKeyPath: [UUID: () -> Void]] = [:] + private var observers: [AnyKeyPath: [UUID: @Sendable () -> Void]] = [:] private let lock = NSLock() private init() {} @@ -36,7 +36,7 @@ public final class DIContainer { @discardableResult func addObserver( for keyPath: KeyPath, - handler: @escaping () -> Void + handler: @escaping @Sendable () -> Void ) -> UUID { let id = UUID() lock.withLock { @@ -54,7 +54,7 @@ public final class DIContainer { } private func notifyObservers(for keyPath: AnyKeyPath) { - let handlers: [() -> Void] = lock.withLock { + let handlers: [@Sendable () -> Void] = lock.withLock { Array(observers[keyPath]?.values ?? []) } handlers.forEach { $0() }