preact-spatial-navigation
Version:
A powerful Preact library for TV-style spatial navigation with LRUD algorithm, virtualized lists/grids, and smart TV support
45 lines • 1.21 kB
TypeScript
import type { FocusDetail } from '../types';
/**
* Events emitted by the spatial navigation system
*/
export type NavigationEvents = {
'focus': FocusDetail;
'blur': FocusDetail;
'willmove': {
direction: string;
sectionId?: string;
};
'navigatefailed': {
direction: string;
};
'enterdown': void;
'enterup': void;
[key: string]: any;
};
/**
* Event bus for spatial navigation events
* Uses mitt.js for lightweight event emission
*/
declare class NavigationEventBus {
private emitter;
constructor();
/**
* Subscribe to a navigation event
*/
on<K extends keyof NavigationEvents>(event: K, handler: (data: NavigationEvents[K]) => void): void;
/**
* Unsubscribe from a navigation event
*/
off<K extends keyof NavigationEvents>(event: K, handler: (data: NavigationEvents[K]) => void): void;
/**
* Emit a navigation event
*/
emit<K extends keyof NavigationEvents>(event: K, data: NavigationEvents[K]): void;
/**
* Clear all event handlers
*/
clear(): void;
}
export declare const navigationEventBus: NavigationEventBus;
export {};
//# sourceMappingURL=eventBus.d.ts.map