20 lines
849 B
Swift
20 lines
849 B
Swift
import Foundation
|
|
|
|
/// The registry's internal source abstraction.
|
|
///
|
|
/// phbar ships no compiled event sources; every live source is an
|
|
/// `PHExternalEventSource` wrapping a `dlopen`'d `PHEventRecognizer`. This
|
|
/// protocol is the registry's main-actor-isolated seam: the adapter conforms,
|
|
/// and tests inject a fake conformer. The `notify` closure is `@MainActor`-
|
|
/// isolated and `Sendable`; the adapter performs the recognizer→main hop.
|
|
@MainActor
|
|
protocol PHEventSource: AnyObject {
|
|
/// Begin observing. `notify` must be retained for as long as the source is
|
|
/// started and is invoked on the main actor for every state change.
|
|
/// Idempotent: calling `start` while already started is a no-op.
|
|
func start(notify: @escaping @MainActor @Sendable () -> Void)
|
|
|
|
/// Stop observing and release system resources. Idempotent.
|
|
func stop()
|
|
}
|