From 905e3fc5bd3e68a88167a9faa28bf604e6c3697c Mon Sep 17 00:00:00 2001 From: Eric Lewis Date: Wed, 22 May 2019 09:23:41 -0700 Subject: [PATCH] Add spec for KeyboardObserver (#24881) Summary: part of #24875. iOS only it appears, but not really used by RN itself. Should be fine? ## Changelog [General] [Added] - Add TM spec for KeyboardObserver Pull Request resolved: https://github.com/facebook/react-native/pull/24881 Reviewed By: fkgozali Differential Revision: D15391769 Pulled By: rickhanlonii fbshipit-source-id: 557507f6063b40d1c68ec8739e23b33bc22ade39 --- Libraries/Components/Keyboard/Keyboard.js | 6 +++--- .../Keyboard/NativeKeyboardObserver.js | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 Libraries/Components/Keyboard/NativeKeyboardObserver.js diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index d4e99f51d8f..976aab0aa7d 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -13,10 +13,10 @@ const LayoutAnimation = require('../../LayoutAnimation/LayoutAnimation'); const invariant = require('invariant'); const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter'); -const KeyboardObserver = require('../../BatchedBridge/NativeModules') - .KeyboardObserver; const dismissKeyboard = require('../../Utilities/dismissKeyboard'); -const KeyboardEventEmitter = new NativeEventEmitter(KeyboardObserver); + +import NativeKeyboardObserver from './NativeKeyboardObserver'; +const KeyboardEventEmitter = new NativeEventEmitter(NativeKeyboardObserver); export type KeyboardEventName = | 'keyboardWillShow' diff --git a/Libraries/Components/Keyboard/NativeKeyboardObserver.js b/Libraries/Components/Keyboard/NativeKeyboardObserver.js new file mode 100644 index 00000000000..792cf7c0757 --- /dev/null +++ b/Libraries/Components/Keyboard/NativeKeyboardObserver.js @@ -0,0 +1,21 @@ +/** + * 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.get('KeyboardObserver');