Refactoring

This commit is contained in:
2025-11-07 20:38:09 +02:00
parent 5566f6f6ba
commit 5bbb722b20
26 changed files with 1097 additions and 770 deletions

View File

@@ -0,0 +1,33 @@
import Foundation
extension Notification {
/// A strongly typed key used to access values in a notifications user info dictionary.
///
/// ## Overview
///
/// `UserInfoKey` provides type safety when working with `Notification.userInfo`, replacing raw
/// string literals with well-defined constants. This helps prevent typos and improves
/// discoverability in database- or system-related notifications.
///
/// ## Topics
///
/// ### Keys
///
/// - ``action``
public struct UserInfoKey: RawRepresentable, Hashable, Sendable {
/// The raw string value of the key.
public let rawValue: String
/// The key used to store the action associated with a notification.
public static let action = Self(rawValue: "action")
/// Creates a user info key from the provided raw string value.
///
/// Returns `nil` if the raw value is invalid.
///
/// - Parameter rawValue: The raw string value of the key.
public init?(rawValue: String) {
self.rawValue = rawValue
}
}
}

View File

@@ -0,0 +1,9 @@
import Foundation
public extension NotificationCenter {
/// The notification center dedicated to database events.
///
/// Use this instance to post and observe notifications related to database lifecycle and
/// operations instead of using the shared `NotificationCenter.default`.
static let database = NotificationCenter()
}