From 2220ab8ab45bcd1fd78eb9f970d94032f6b7a996 Mon Sep 17 00:00:00 2001 From: Oleksii Zghurskyi Date: Thu, 13 Nov 2025 17:52:29 +0200 Subject: [PATCH] Make database notification center optional --- Sources/DataRaft/Classes/DatabaseService.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/DataRaft/Classes/DatabaseService.swift b/Sources/DataRaft/Classes/DatabaseService.swift index 6c74098..79686fa 100644 --- a/Sources/DataRaft/Classes/DatabaseService.swift +++ b/Sources/DataRaft/Classes/DatabaseService.swift @@ -65,7 +65,7 @@ open class DatabaseService: { // MARK: - Properties - private let center: NotificationCenter + private let center: NotificationCenter? /// Notification posted after the database content changes with this service. public static let databaseDidChange = Notification.Name("DatabaseService.databaseDidChange") @@ -86,12 +86,12 @@ open class DatabaseService: /// - config: An optional configuration closure called after the connection is established and /// the encryption key is applied. /// - queue: An optional target queue for the internal one. - /// - center: The notification center used to post database change notifications. + /// - center: An optional notification center used to post database change notifications. public init( provider: @escaping ConnectionProvider, config: ConnectionConfig? = nil, queue: DispatchQueue? = nil, - center: NotificationCenter + center: NotificationCenter? ) { self.center = center super.init(provider: provider, config: config, queue: queue) @@ -142,7 +142,7 @@ open class DatabaseService: let changes = connection.totalChanges defer { if changes != connection.totalChanges { - center.post(name: Self.databaseDidChange, object: self) + center?.post(name: Self.databaseDidChange, object: self) } } return try closure(connection)