Skip to content

Commit

Permalink
Switch to "discrete" and "continuous" terminology
Browse files Browse the repository at this point in the history
Events were previously described as "interactive" or "non-interactive".
  • Loading branch information
acdlite committed Jun 1, 2019
1 parent 73c380f commit 91635dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/events/ReactSyntheticEventType.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type DispatchConfig = {
captured: string,
},
registrationName?: string,
isInteractive?: boolean,
isDiscrete?: boolean,
};

export type ReactSyntheticEvent = {
Expand Down
10 changes: 5 additions & 5 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {passiveBrowserEventsSupported} from './checkPassiveEvents';

import {enableEventAPI} from 'shared/ReactFeatureFlags';

const {isInteractiveTopLevelEventType} = SimpleEventPlugin;
const {isDiscreteTopLevelEventType} = SimpleEventPlugin;

const CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
const callbackBookkeepingPool = [];
Expand Down Expand Up @@ -215,11 +215,11 @@ function trapEventForPluginEventSystem(
topLevelType: DOMTopLevelEventType,
capture: boolean,
): void {
const dispatch = isInteractiveTopLevelEventType(topLevelType)
? dispatchInteractiveEvent
const dispatch = isDiscreteTopLevelEventType(topLevelType)
? dispatchDiscreteEvent
: dispatchEvent;
const rawEventName = getRawEventName(topLevelType);
// Check if interactive and wrap in discreteUpdates
// Check if discrete and wrap in discreteUpdates
const listener = dispatch.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
if (capture) {
addEventCaptureListener(element, rawEventName, listener);
Expand All @@ -228,7 +228,7 @@ function trapEventForPluginEventSystem(
}
}

function dispatchInteractiveEvent(topLevelType, eventSystemFlags, nativeEvent) {
function dispatchDiscreteEvent(topLevelType, eventSystemFlags, nativeEvent) {
if (!enableEventAPI || shouldflushDiscreteUpdates(nativeEvent.timeStamp)) {
flushDiscreteUpdates();
}
Expand Down
18 changes: 9 additions & 9 deletions packages/react-dom/src/events/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import getEventCharCode from './getEventCharCode';
* ]);
*/
type EventTuple = [DOMTopLevelEventType, string];
const interactiveEventTypeNames: Array<EventTuple> = [
const discreteEventTypeNames: Array<EventTuple> = [
[DOMTopLevelEventTypes.TOP_BLUR, 'blur'],
[DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'],
[DOMTopLevelEventTypes.TOP_CLICK, 'click'],
Expand Down Expand Up @@ -92,7 +92,7 @@ const interactiveEventTypeNames: Array<EventTuple> = [
[DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart'],
[DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'],
];
const nonInteractiveEventTypeNames: Array<EventTuple> = [
const continuousEventTypeNames: Array<EventTuple> = [
[DOMTopLevelEventTypes.TOP_ABORT, 'abort'],
[DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'],
[DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'],
Expand Down Expand Up @@ -142,7 +142,7 @@ const topLevelEventsToDispatchConfig: {

function addEventTypeNameToConfig(
[topEvent, event]: EventTuple,
isInteractive: boolean,
isDiscrete: boolean,
) {
const capitalizedEvent = event[0].toUpperCase() + event.slice(1);
const onEvent = 'on' + capitalizedEvent;
Expand All @@ -153,16 +153,16 @@ function addEventTypeNameToConfig(
captured: onEvent + 'Capture',
},
dependencies: [topEvent],
isInteractive,
isDiscrete,
};
eventTypes[event] = type;
topLevelEventsToDispatchConfig[topEvent] = type;
}

interactiveEventTypeNames.forEach(eventTuple => {
discreteEventTypeNames.forEach(eventTuple => {
addEventTypeNameToConfig(eventTuple, true);
});
nonInteractiveEventTypeNames.forEach(eventTuple => {
continuousEventTypeNames.forEach(eventTuple => {
addEventTypeNameToConfig(eventTuple, false);
});

Expand Down Expand Up @@ -202,13 +202,13 @@ const knownHTMLTopLevelTypes: Array<DOMTopLevelEventType> = [
];

const SimpleEventPlugin: PluginModule<MouseEvent> & {
isInteractiveTopLevelEventType: (topLevelType: TopLevelType) => boolean,
isDiscreteTopLevelEventType: (topLevelType: TopLevelType) => boolean,
} = {
eventTypes: eventTypes,

isInteractiveTopLevelEventType(topLevelType: TopLevelType): boolean {
isDiscreteTopLevelEventType(topLevelType: TopLevelType): boolean {
const config = topLevelEventsToDispatchConfig[topLevelType];
return config !== undefined && config.isInteractive === true;
return config !== undefined && config.isDiscrete === true;
},

extractEvents: function(
Expand Down

0 comments on commit 91635dd

Please sign in to comment.