import Foundation

class NotificationHandler {
    var onNavigateToURL: ((URL) -> Void)?

    init() {
        NotificationCenter.default.addObserver(self, selector: #selector(handleNotification(_:)), name: .navigateToURL, object: nil)
    }

    deinit {
        NotificationCenter.default.removeObserver(self)
    }

    @objc private func handleNotification(_ notification: Notification) {
        if let url = notification.object as? URL {
            onNavigateToURL?(url)
        }
    }
}
