@@ -50,10 +50,10 @@ class EventEmitter {
50
50
* listener
51
51
*/
52
52
addListener ( eventType , listener , context ) {
53
- return ( this . _subscriber . addSubscription (
53
+ return this . _subscriber . addSubscription (
54
54
eventType ,
55
- new EmitterSubscription ( this , this . _subscriber , listener , context )
56
- ) ) ;
55
+ new EmitterSubscription ( this , this . _subscriber , listener , context ) ,
56
+ ) ;
57
57
}
58
58
59
59
/**
@@ -96,19 +96,19 @@ class EventEmitter {
96
96
*
97
97
* @example
98
98
* var subscription = emitter.addListenerMap({
99
- * someEvent: function(data, event) {
100
- * console.log(data);
101
- * emitter.removeCurrentListener();
102
- * }
103
- * });
99
+ * someEvent: function(data, event) {
100
+ * console.log(data);
101
+ * emitter.removeCurrentListener();
102
+ * }
103
+ * });
104
104
*
105
105
* emitter.emit('someEvent', 'abc'); // logs 'abc'
106
106
* emitter.emit('someEvent', 'def'); // does not log anything
107
107
*/
108
108
removeCurrentListener ( ) {
109
109
invariant (
110
110
! ! this . _currentSubscription ,
111
- 'Not in an emitting cycle; there is no current subscription'
111
+ 'Not in an emitting cycle; there is no current subscription' ,
112
112
) ;
113
113
this . removeSubscription ( this . _currentSubscription ) ;
114
114
}
@@ -120,7 +120,7 @@ class EventEmitter {
120
120
removeSubscription ( subscription ) {
121
121
invariant (
122
122
subscription . emitter === this ,
123
- 'Subscription does not belong to this emitter.'
123
+ 'Subscription does not belong to this emitter.' ,
124
124
) ;
125
125
this . _subscriber . removeSubscription ( subscription ) ;
126
126
}
@@ -133,8 +133,10 @@ class EventEmitter {
133
133
* @returns {array }
134
134
*/
135
135
listeners ( eventType ) {
136
- const subscriptions = ( this . _subscriber . getSubscriptionsForType ( eventType ) ) ;
137
- return subscriptions ? subscriptions . map ( subscription => subscription . listener ) : [ ] ;
136
+ const subscriptions = this . _subscriber . getSubscriptionsForType ( eventType ) ;
137
+ return subscriptions
138
+ ? subscriptions . map ( subscription => subscription . listener )
139
+ : [ ] ;
138
140
}
139
141
140
142
/**
@@ -146,13 +148,13 @@ class EventEmitter {
146
148
*
147
149
* @example
148
150
* emitter.addListener('someEvent', function(message) {
149
- * console.log(message);
150
- * });
151
+ * console.log(message);
152
+ * });
151
153
*
152
154
* emitter.emit('someEvent', 'abc'); // logs 'abc'
153
155
*/
154
156
emit ( eventType ) {
155
- const subscriptions = ( this . _subscriber . getSubscriptionsForType ( eventType ) ) ;
157
+ const subscriptions = this . _subscriber . getSubscriptionsForType ( eventType ) ;
156
158
if ( subscriptions ) {
157
159
for ( let i = 0 , l = subscriptions . length ; i < l ; i ++ ) {
158
160
const subscription = subscriptions [ i ] ;
@@ -162,7 +164,7 @@ class EventEmitter {
162
164
this . _currentSubscription = subscription ;
163
165
subscription . listener . apply (
164
166
subscription . context ,
165
- Array . prototype . slice . call ( arguments , 1 )
167
+ Array . prototype . slice . call ( arguments , 1 ) ,
166
168
) ;
167
169
}
168
170
}
@@ -179,12 +181,12 @@ class EventEmitter {
179
181
*
180
182
* @example
181
183
* emitter.removeListener('someEvent', function(message) {
182
- * console.log(message);
183
- * }); // removes the listener if already registered
184
+ * console.log(message);
185
+ * }); // removes the listener if already registered
184
186
*
185
187
*/
186
188
removeListener ( eventType , listener ) {
187
- const subscriptions = ( this . _subscriber . getSubscriptionsForType ( eventType ) ) ;
189
+ const subscriptions = this . _subscriber . getSubscriptionsForType ( eventType ) ;
188
190
if ( subscriptions ) {
189
191
for ( let i = 0 , l = subscriptions . length ; i < l ; i ++ ) {
190
192
const subscription = subscriptions [ i ] ;
0 commit comments