mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-02 02:22:25 +00:00
Rename Notifications.swift to AppNotifications.swift.
This commit is contained in:
1 parent
6b2ed7c6e0
commit
16ac60ba41
2 files changed
+36
-29
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Notifications.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 3/7/26.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os
|
||||
|
||||
public extension Notification.Name {
|
||||
|
||||
/// Posted on actual low memory condition. Posted on main thread.
|
||||
static let lowMemory = Notification.Name("LowMemoryNotification")
|
||||
|
||||
/// Posted when the app goes to background. Posted on main thread.
|
||||
static let appDidGoToBackground = Notification.Name("AppDidGoToBackgroundNotification")
|
||||
}
|
||||
|
||||
private let notificationLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Notifications.swift")
|
||||
|
||||
public func postLowMemoryNotification() {
|
||||
NotificationCenter.default.postOnMainThread(name: .lowMemory, object: nil)
|
||||
}
|
||||
|
||||
public func postAppDidGoToBackgroundNotification() {
|
||||
if Thread.isMainThread {
|
||||
lowMemoryLogger.info("Posting app did go to background notification")
|
||||
NotificationCenter.default.post(name: .appDidGoToBackground, object: nil)
|
||||
} else {
|
||||
Task { @MainActor in
|
||||
lowMemoryLogger.info("Posting app did go to background notification")
|
||||
NotificationCenter.default.post(name: .appDidGoToBackground, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// Notifications.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 3/7/26.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os
|
||||
|
||||
public extension Notification.Name {
|
||||
/// Posted when the app should free memory — on background transition
|
||||
/// and potentially on memory warnings. Always posted on the main thread.
|
||||
static let lowMemory = Notification.Name("LowMemoryNotification")
|
||||
}
|
||||
|
||||
private let lowMemoryLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "LowMemory")
|
||||
|
||||
public func postLowMemoryNotification() {
|
||||
if Thread.isMainThread {
|
||||
lowMemoryLogger.info("Posting low memory notification")
|
||||
NotificationCenter.default.post(name: .lowMemory, object: nil)
|
||||
} else {
|
||||
Task { @MainActor in
|
||||
lowMemoryLogger.info("Posting low memory notification")
|
||||
NotificationCenter.default.post(name: .lowMemory, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user