Skip to content

Commit

Permalink
fix: use correct return types for addReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Akazm committed Dec 16, 2024
1 parent b153b81 commit 6033aac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/TapGuard/HIDEventDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public final class HIDEventDispatcher: Sendable {
/// - Returns: An object that can be removed from this `HIDEventDispatcher` by calling ``HIDEventReceiverClosure/remove``
public func addReceiver(
_ receiver: @escaping @Sendable (CopiedCGEvent) -> Void
) -> AnyHIDEventReceiver {
) -> HIDEventReceiverClosure {
addReceiver { event in
receiver(event)
return .pass
Expand All @@ -68,7 +68,7 @@ public final class HIDEventDispatcher: Sendable {
/// - Returns: An object that can be removed from this `HIDEventDispatcher` by calling ``HIDEventReceiverClosure/remove``
public func addReceiver(
_ receiver: @escaping @Sendable (CopiedCGEvent) -> PostProcessHIDEventInstruction
) -> AnyHIDEventReceiver {
) -> HIDEventReceiverClosure {
let box = UncheckedWeakSendable<HIDEventReceiverClosure>(nil)
let newReceiver = HIDEventReceiverClosure(closure: receiver) { [weak self] in
if let newReceiver = box.value {
Expand All @@ -86,7 +86,7 @@ public final class HIDEventDispatcher: Sendable {
/// - Returns: An object that can be removed from this `HIDEventDispatcher` by calling ``HIDEventReceiverClosure/remove``
public func addReceiver(
_ receiver: @escaping @Sendable (CopiedCGEvent) async -> Void
) -> AnyHIDEventReceiver {
) -> HIDEventReceiverClosure {
addReceiver { event in
await receiver(event)
return .pass
Expand All @@ -99,7 +99,7 @@ public final class HIDEventDispatcher: Sendable {
/// - Returns: An object that can be removed from this `HIDEventDispatcher` by calling ``HIDEventReceiverClosure/remove``
public func addReceiver(
_ receiver: @escaping @Sendable (CopiedCGEvent) async -> PostProcessHIDEventInstruction
) -> AnyHIDEventReceiver {
) -> HIDEventReceiverClosure {
let box = UncheckedWeakSendable<HIDEventReceiverClosure>(nil)
let newReceiver = HIDEventReceiverClosure(closure: receiver) { [weak self] in
if let newReceiver = box.value {
Expand Down

0 comments on commit 6033aac

Please sign in to comment.