Remove keyMirror in PropagationPhases (#7596)
See rationale in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/
Christopher Chedeau committed
Aug 30, 2016 at 09:44 UTC
738a9e3ef25db863126cd7ec2b37b9ba0bd1c7c2
2 files changed
+5
-6
src/renderers/shared/stack/event/EventConstants.js
+1
-2
@@ -13,7 +13,7 @@
13
14
var keyMirror = require('keyMirror');
15
16
-var PropagationPhases = keyMirror({bubbled: null, captured: null});
16
+export type PropagationPhases = 'bubbled' | 'captured';
17
18
/**
19
* Types of raw signals from the browser caught at the top level.
@@ -91,7 +91,6 @@ var topLevelTypes = keyMirror({
91
92
var EventConstants = {
93
topLevelTypes: topLevelTypes,
94
- PropagationPhases: PropagationPhases,
94
};
95
96
module.exports = EventConstants;
src/renderers/shared/stack/event/EventPropagators.js
+4
-4
@@ -11,7 +11,6 @@
11
12
'use strict';
13
14
-var EventConstants = require('EventConstants');
14
var EventPluginHub = require('EventPluginHub');
15
var EventPluginUtils = require('EventPluginUtils');
16
@@ -19,14 +18,15 @@ var accumulateInto = require('accumulateInto');
18
var forEachAccumulated = require('forEachAccumulated');
19
var warning = require('warning');
20
22
-var PropagationPhases = EventConstants.PropagationPhases;
21
+import type { PropagationPhases } from 'EventConstants';
22
+
23
var getListener = EventPluginHub.getListener;
24
25
/**
26
* Some event types have a notion of different registration names for different
27
* "phases" of propagation. This finds listeners by a given phase.
28
*/
29
-function listenerAtPhase(inst, event, propagationPhase) {
29
+function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) {
30
var registrationName =
31
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
32
return getListener(inst, registrationName);
@@ -45,7 +45,7 @@ function accumulateDirectionalDispatches(inst, upwards, event) {
45
'Dispatching inst must not be null'
46
);
47
}
48
- var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
48
+ var phase = upwards ? 'bubbled' : 'captured';
49
var listener = listenerAtPhase(inst, event, phase);
50
if (listener) {
51
event._dispatchListeners =