diff --git a/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js b/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js new file mode 100644 index 000000000000..ddd666e561b4 --- /dev/null +++ b/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'RCTExport'; +import * as TurboModuleRegistry from 'TurboModuleRegistry'; + +export interface Spec extends TurboModule { + +addListener: (eventName: string) => void; + +removeListeners: (count: number) => void; +} + +export default TurboModuleRegistry.getEnforcing( + 'TVNavigationEventEmitter', +); diff --git a/Libraries/Components/AppleTV/TVEventHandler.js b/Libraries/Components/AppleTV/TVEventHandler.js index debaa0f3418a..852038ba12f5 100644 --- a/Libraries/Components/AppleTV/TVEventHandler.js +++ b/Libraries/Components/AppleTV/TVEventHandler.js @@ -11,10 +11,10 @@ 'use strict'; const Platform = require('../../Utilities/Platform'); -const TVNavigationEventEmitter = require('../../BatchedBridge/NativeModules') - .TVNavigationEventEmitter; const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter'); +import NativeTVNavigationEventEmitter from './NativeTVNavigationEventEmitter'; + function TVEventHandler() { this.__nativeTVNavigationEventListener = null; this.__nativeTVNavigationEventEmitter = null; @@ -24,12 +24,12 @@ TVEventHandler.prototype.enable = function( component: ?any, callback: Function, ) { - if (Platform.OS === 'ios' && !TVNavigationEventEmitter) { + if (Platform.OS === 'ios' && !NativeTVNavigationEventEmitter) { return; } this.__nativeTVNavigationEventEmitter = new NativeEventEmitter( - TVNavigationEventEmitter, + NativeTVNavigationEventEmitter, ); this.__nativeTVNavigationEventListener = this.__nativeTVNavigationEventEmitter.addListener( 'onHWKeyEvent',