View ReducedReplayAsyncStream.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ReducedReplayAsyncStream<Element> { | |
typealias Reduce = (_ partialResult: inout Element, _ nextResult: Element) -> Void | |
private let storage: _Storage | |
private var originalStream: AsyncStream<Element> | |
init( | |
bufferingPolicy limit: AsyncStream<Element>.Continuation.BufferingPolicy = .unbounded, | |
initialResult: Element, |
View EventService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Free to use | |
// Written by Alexis Bridoux - https://github.com/ABridoux | |
import Foundation | |
/// Service to shut down, restart, or put the computer to sleep. Also log out the user. | |
/// | |
/// ### Resources | |
/// - [Apple doc](https://developer.apple.com/library/archive/qa/qa1134/_index.html) | |
/// - Already in use in [SplashBuddy](https://github.com/macadmins/SplashBuddy/blob/main/SplashBuddy/Tools/LoginWindow.swift) |
View NotificationObserver.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Free to use | |
// Written by Alexis Bridoux - https://github.com/ABridoux | |
/// Observes a notification and executes the provided block upon reception | |
/// | |
/// Unregister the stored observer upon deinitialization | |
final class NotificationObserver { | |
var name: Notification.Name | |
var observer: NSObjectProtocol |
View WindowPosition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Free to use | |
// Written by Alexis Bridoux - https://github.com/ABridoux | |
import AppKit | |
#if canImport(SwiftUI) | |
import SwiftUI | |
#endif | |
// MARK: Model |