Skip to content

Commit

Permalink
Remove deprecated on() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 20, 2024
1 parent 04b8db6 commit 09e4a10
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions Sources/KeyboardShortcuts/KeyboardShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -550,37 +550,6 @@ extension KeyboardShortcuts {
public static func events(_ type: EventType, for name: Name) -> AsyncFilterSequence<AsyncStream<EventType>> {
events(for: name).filter { $0 == type }
}

@available(*, deprecated, renamed: "events(_:for:)")
public static func on(_ type: EventType, for name: Name) -> AsyncStream<Void> {
AsyncStream { continuation in
let id = UUID()

switch type {
case .keyDown:
streamKeyDownHandlers[name, default: [:]][id] = {
continuation.yield()
}
case .keyUp:
streamKeyUpHandlers[name, default: [:]][id] = {
continuation.yield()
}
}

registerShortcutIfNeeded(for: name)

continuation.onTermination = { _ in
switch type {
case .keyDown:
streamKeyDownHandlers[name]?[id] = nil
case .keyUp:
streamKeyUpHandlers[name]?[id] = nil
}

unregisterShortcutIfNeeded(for: name)
}
}
}
}

extension Notification.Name {
Expand Down

0 comments on commit 09e4a10

Please sign in to comment.