Skip to content

Commit dd92dba

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Turn on Flow for EventEmitter
Reviewed By: sahrens Differential Revision: D5732809 fbshipit-source-id: b8241120188b2b64af12249b2f00a43bea3b58a4
1 parent 1f9fc0e commit dd92dba

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

Libraries/EventEmitter/MissingNativeEventEmitterShim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MissingNativeEventEmitterShim extends EventEmitter {
3838
}
3939

4040
// EventEmitter
41-
addListener(eventType: string, listener: Function, context: ?Object): EmitterSubscription {
41+
addListener(eventType: string, listener: Function, context: ?Object) {
4242
this.throwMissingNativeModule();
4343
}
4444

Libraries/Network/XMLHttpRequest.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) {
394394

395395
_clearSubscriptions(): void {
396396
(this._subscriptions || []).forEach(sub => {
397-
sub.remove();
397+
if (sub) {
398+
sub.remove();
399+
}
398400
});
399401
this._subscriptions = [];
400402
}

Libraries/vendor/emitter/EmitterSubscription.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule EmitterSubscription
10-
* @noflow
10+
* @flow
1111
*/
1212
'use strict';
1313

Libraries/vendor/emitter/mixInEventEmitter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const EventHolder = require('EventHolder');
1818
const invariant = require('fbjs/lib/invariant');
1919
const keyOf = require('fbjs/lib/keyOf');
2020

21+
import type EmitterSubscription from 'EmitterSubscription';
22+
2123
const TYPES_KEY = keyOf({__types: true});
2224

2325
/**
@@ -79,7 +81,7 @@ const EventEmitterMixin = {
7981
return this.__getEventEmitter().emitAndHold(eventType, a, b, c, d, e, _);
8082
},
8183

82-
addListener: function(eventType, listener, context) {
84+
addListener: function(eventType, listener, context): EmitterSubscription {
8385
return this.__getEventEmitter().addListener(eventType, listener, context);
8486
},
8587

local-cli/templates/HelloNavigation/components/KeyboardSpacer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class KeyboardSpacerIOS extends Component<Props, State> {
6767
this._unRegisterEvents();
6868
}
6969

70-
_keyboardWillShowSubscription: { remove: Function };
71-
_keyboardWillHideSubscription: { remove: Function };
70+
_keyboardWillShowSubscription: { +remove: Function };
71+
_keyboardWillHideSubscription: { +remove: Function };
7272

7373
_registerEvents = () => {
7474
this._keyboardWillShowSubscription = Keyboard.addListener(

0 commit comments

Comments
 (0)