Add spec for NativeDeviceEventManager (#24914)

Summary:
Part of #24875.

## Changelog

[General] [Added] - TM add spec for NativeDeviceEventManager
Pull Request resolved: https://github.com/facebook/react-native/pull/24914

Reviewed By: RSNara

Differential Revision: D15421462

Pulled By: fkgozali

fbshipit-source-id: 78b90c615cd031ecd010a552751e506406ab739a
This commit is contained in:
Uilque Messias 2019-05-20 18:00:34 -07:00 коммит произвёл Facebook Github Bot
Родитель 6c573f71f1
Коммит 580088c199
2 изменённых файлов: 27 добавлений и 4 удалений

Просмотреть файл

@ -0,0 +1,20 @@
/**
* 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 strict-local
* @format
*/
'use strict';
import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
export interface Spec extends TurboModule {
+invokeDefaultBackPressHandler: () => void;
}
export default TurboModuleRegistry.get<Spec>('DeviceEventManager');

Просмотреть файл

@ -10,9 +10,8 @@
'use strict';
const DeviceEventManager = require('../BatchedBridge/NativeModules')
.DeviceEventManager;
const RCTDeviceEventEmitter = require('../EventEmitter/RCTDeviceEventEmitter');
import NativeDeviceEventManager from '../../Libraries/NativeModules/specs/NativeDeviceEventManager';
import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
const DEVICE_BACK_EVENT = 'hardwareBackPress';
@ -73,7 +72,11 @@ type TBackHandler = {|
|};
const BackHandler: TBackHandler = {
exitApp: function(): void {
DeviceEventManager.invokeDefaultBackPressHandler();
if (!NativeDeviceEventManager) {
return;
}
NativeDeviceEventManager.invokeDefaultBackPressHandler();
},
/**