File tree Expand file tree Collapse file tree
packages/rn-tester/js/examples/Accessibility Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,38 +127,6 @@ class AppState {
127127 }
128128 throw new Error ( 'Trying to subscribe to unknown event: ' + type ) ;
129129 }
130-
131- /**
132- * @deprecated Use `remove` on the EventSubscription from `addEventListener`.
133- */
134- removeEventListener< K : $Keys < AppStateEventDefinitions > > (
135- type : K ,
136- listener : ( ...$ElementType < AppStateEventDefinitions , K > ) => mixed ,
137- ) : void {
138- const emitter = this . _emitter ;
139- if ( emitter == null ) {
140- throw new Error ( 'Cannot use AppState when `isAvailable` is false.' ) ;
141- }
142- // NOTE: This will report a deprecation notice via `console.error`.
143- switch ( type ) {
144- case 'change' :
145- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
146- // $FlowIssue[incompatible-call]
147- emitter . removeListener ( 'appStateDidChange' , listener ) ;
148- return ;
149- case 'memoryWarning' :
150- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
151- emitter . removeListener ( 'memoryWarning' , listener ) ;
152- return ;
153- case 'blur' :
154- case 'focus' :
155- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
156- // $FlowIssue[incompatible-call]
157- emitter . removeListener ( 'appStateFocusChange' , listener ) ;
158- return ;
159- }
160- throw new Error('Trying to unsubscribe from unknown event: ' + type);
161- }
162130}
163131
164132module . exports = ( new AppState ( ) : AppState ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
1212import { sendAccessibilityEvent } from '../../Renderer/shims/ReactNative' ;
1313import type { HostComponent } from '../../Renderer/shims/ReactNativeTypes' ;
1414import Platform from '../../Utilities/Platform' ;
15- import type EventEmitter from '../../vendor/emitter/EventEmitter' ;
1615import type { EventSubscription } from '../../vendor/emitter/EventEmitter' ;
1716import NativeAccessibilityInfoAndroid from './NativeAccessibilityInfo' ;
1817import NativeAccessibilityManagerIOS from './NativeAccessibilityManager' ;
@@ -365,25 +364,6 @@ const AccessibilityInfo = {
365364 }
366365 } ,
367366
368- /**
369- * @deprecated Use `remove` on the EventSubscription from `addEventListener`.
370- */
371- removeEventListener < K : $Keys < AccessibilityEventDefinitions >> (
372- eventName : K ,
373- handler : ( ...$ElementType < AccessibilityEventDefinitions , K > ) => void ,
374- ) : void {
375- // NOTE: This will report a deprecation notice via `console.error`.
376- const deviceEventName = EventNames . get ( eventName ) ;
377- if ( deviceEventName != null ) {
378- // $FlowIgnore[incompatible-cast]
379- ( RCTDeviceEventEmitter : EventEmitter < $FlowFixMe > ) . removeListener (
380- 'deviceEventName' ,
381- // $FlowFixMe[invalid-tuple-arity]
382- handler ,
383- ) ;
384- }
385- } ,
386-
387367 /**
388368 * Get the recommended timeout for changes to the UI needed by this user.
389369 *
Original file line number Diff line number Diff line change @@ -141,17 +141,6 @@ class Keyboard {
141141 return this . _emitter . addListener ( eventType , listener ) ;
142142 }
143143
144- /**
145- * @deprecated Use `remove` on the EventSubscription from `addListener`.
146- */
147- removeListener< K : $Keys < KeyboardEventDefinitions > > (
148- eventType : K ,
149- listener : ( ...$ElementType < KeyboardEventDefinitions , K > ) => mixed ,
150- ) : void {
151- // NOTE: This will report a deprecation notice via `console.error`.
152- this . _emitter . removeListener ( eventType , listener ) ;
153- }
154-
155144 /**
156145 * Removes all listeners for a specific event type.
157146 *
Original file line number Diff line number Diff line change @@ -95,19 +95,6 @@ export default class NativeEventEmitter<TEventToArgsMap: {...}>
9595 } ;
9696 }
9797
98- /**
99- * @deprecated Use `remove` on the EventSubscription from `addListener`.
100- */
101- removeListener< TEvent : $Keys < TEventToArgsMap > > (
102- eventType : TEvent ,
103- listener : ( ...args : $ElementType < TEventToArgsMap , TEvent > ) => mixed ,
104- ) : void {
105- this . _nativeModule ?. removeListeners ( 1 ) ;
106- // NOTE: This will report a deprecation notice via `console.error`.
107- // $FlowFixMe[prop-missing] - `removeListener` exists but is deprecated.
108- RCTDeviceEventEmitter . removeListener ( eventType , listener ) ;
109- }
110-
11198 emit< TEvent : $Keys < TEventToArgsMap > > (
11299 eventType : TEvent ,
113100 ...args : $ElementType < TEventToArgsMap , TEvent >
Original file line number Diff line number Diff line change @@ -46,17 +46,6 @@ class Linking extends NativeEventEmitter<LinkingEventDefinitions> {
4646 return this . addListener ( eventType , listener ) ;
4747 }
4848
49- /**
50- * @deprecated Use `remove` on the EventSubscription from `addEventListener`.
51- */
52- removeEventListener < K : $Keys < LinkingEventDefinitions >> (
53- eventType : K ,
54- listener : ( ...$ElementType < LinkingEventDefinitions , K > ) => mixed ,
55- ) : void {
56- // NOTE: This will report a deprecation notice via `console.error`.
57- this. removeListener ( eventType , listener ) ;
58- }
59-
6049 /**
6150 * Try to open the given `url` with any of the installed apps.
6251 *
Original file line number Diff line number Diff line change @@ -108,19 +108,6 @@ class Dimensions {
108108 ) ;
109109 return eventEmitter . addListener ( type , handler ) ;
110110 }
111-
112- /**
113- * @deprecated Use `remove` on the EventSubscription from `addEventListener`.
114- */
115- static removeEventListener ( type : 'change' , handler : Function ) {
116- invariant (
117- type === 'change' ,
118- 'Trying to remove listener for unknown event: "%s"' ,
119- type ,
120- ) ;
121- // NOTE: This will report a deprecation notice via `console.error`.
122- eventEmitter . removeListener ( type , handler ) ;
123- }
124111}
125112
126113let initialDims : ?$ReadOnly < DimensionsPayload > =
Original file line number Diff line number Diff line change @@ -152,33 +152,6 @@ class EventEmitter<EventDefinitions: {...}> {
152152 }
153153 }
154154 }
155-
156- /**
157- * @deprecated Use `remove` on the EventSubscription from `addListener`.
158- */
159- removeListener < K : $Keys < EventDefinitions >> (
160- eventType : K ,
161- // FIXME: listeners should return void instead of mixed to prevent issues
162- listener : ( ...$ElementType < EventDefinitions , K > ) => mixed ,
163- ) : void {
164- console . warn (
165- `EventEmitter.removeListener('${ eventType } ', ...): Method has been ` +
166- 'deprecated. Please instead use `remove()` on the subscription ' +
167- 'returned by `EventEmitter.addListener`.' ,
168- ) ;
169- const subscriptions = this . _subscriber . getSubscriptionsForType ( eventType ) ;
170- if ( subscriptions ) {
171- for ( let i = 0 , l = subscriptions . length ; i < l ; i ++ ) {
172- const subscription = subscriptions [ i ] ;
173-
174- // The subscription may have been removed during this event loop.
175- // its listener matches the listener in method parameters
176- if ( subscription && subscription . listener === listener ) {
177- subscription . remove ( ) ;
178- }
179- }
180- }
181- }
182155}
183156
184157module . exports = EventEmitter ;
Original file line number Diff line number Diff line change @@ -1151,12 +1151,15 @@ class DisplayOptionsStatusExample extends React.Component<{}> {
11511151function DisplayOptionStatusExample ( { optionName , optionChecker , notification } ) {
11521152 const [ statusEnabled , setStatusEnabled ] = React . useState ( false ) ;
11531153 React . useEffect ( ( ) => {
1154- AccessibilityInfo . addEventListener ( notification , setStatusEnabled ) ;
1154+ const listener = AccessibilityInfo . addEventListener (
1155+ notification ,
1156+ setStatusEnabled ,
1157+ ) ;
11551158 optionChecker ( ) . then ( isEnabled => {
11561159 setStatusEnabled ( isEnabled ) ;
11571160 } ) ;
11581161 return function cleanup ( ) {
1159- AccessibilityInfo . removeEventListener ( notification , setStatusEnabled ) ;
1162+ listener . remove ( ) ;
11601163 } ;
11611164 } , [ optionChecker , notification ] ) ;
11621165 return (
You can’t perform that action at this time.
0 commit comments