Add database change notification

This commit is contained in:
2025-11-09 17:23:08 +02:00
parent 5bbb722b20
commit df17d21ec4
6 changed files with 84 additions and 112 deletions

View File

@@ -1,33 +0,0 @@
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

@@ -5,5 +5,5 @@ public extension NotificationCenter {
///
/// 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()
static let databaseCenter = NotificationCenter()
}