mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Post a notification when a LogItem is added.
This commit is contained in:
@@ -8,9 +8,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension Notification.Name {
|
||||
|
||||
public static let LogDidAddItem = NSNotification.Name("LogDidAddItem")
|
||||
}
|
||||
|
||||
public class Log {
|
||||
|
||||
public var logItems = [LogItem]()
|
||||
public static let logItemKey = "logItem" // userInfo key
|
||||
private let lock = NSLock()
|
||||
|
||||
public init() {
|
||||
// Satisfy compiler
|
||||
@@ -18,6 +25,10 @@ public class Log {
|
||||
|
||||
public func add(_ logItem: LogItem) {
|
||||
|
||||
lock.lock()
|
||||
logItems += [logItem]
|
||||
lock.unlock()
|
||||
|
||||
NotificationCenter.default.post(name: .LogDidAddItem, object: self, userInfo: [Log.logItemKey: logItem])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user