Turn on Flow for EventEmitter
Reviewed By: sahrens Differential Revision: D5732809 fbshipit-source-id: b8241120188b2b64af12249b2f00a43bea3b58a4
This commit is contained in:
Родитель
1f9fc0ee3a
Коммит
dd92dba3da
|
@ -38,7 +38,7 @@ class MissingNativeEventEmitterShim extends EventEmitter {
|
|||
}
|
||||
|
||||
// EventEmitter
|
||||
addListener(eventType: string, listener: Function, context: ?Object): EmitterSubscription {
|
||||
addListener(eventType: string, listener: Function, context: ?Object) {
|
||||
this.throwMissingNativeModule();
|
||||
}
|
||||
|
||||
|
|
|
@ -394,7 +394,9 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) {
|
|||
|
||||
_clearSubscriptions(): void {
|
||||
(this._subscriptions || []).forEach(sub => {
|
||||
sub.remove();
|
||||
if (sub) {
|
||||
sub.remove();
|
||||
}
|
||||
});
|
||||
this._subscriptions = [];
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule EmitterSubscription
|
||||
* @noflow
|
||||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ const EventHolder = require('EventHolder');
|
|||
const invariant = require('fbjs/lib/invariant');
|
||||
const keyOf = require('fbjs/lib/keyOf');
|
||||
|
||||
import type EmitterSubscription from 'EmitterSubscription';
|
||||
|
||||
const TYPES_KEY = keyOf({__types: true});
|
||||
|
||||
/**
|
||||
|
@ -79,7 +81,7 @@ const EventEmitterMixin = {
|
|||
return this.__getEventEmitter().emitAndHold(eventType, a, b, c, d, e, _);
|
||||
},
|
||||
|
||||
addListener: function(eventType, listener, context) {
|
||||
addListener: function(eventType, listener, context): EmitterSubscription {
|
||||
return this.__getEventEmitter().addListener(eventType, listener, context);
|
||||
},
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ class KeyboardSpacerIOS extends Component<Props, State> {
|
|||
this._unRegisterEvents();
|
||||
}
|
||||
|
||||
_keyboardWillShowSubscription: { remove: Function };
|
||||
_keyboardWillHideSubscription: { remove: Function };
|
||||
_keyboardWillShowSubscription: { +remove: Function };
|
||||
_keyboardWillHideSubscription: { +remove: Function };
|
||||
|
||||
_registerEvents = () => {
|
||||
this._keyboardWillShowSubscription = Keyboard.addListener(
|
||||
|
|
Загрузка…
Ссылка в новой задаче