Convert react-native-github/Libraries to let/const

Reviewed By: sahrens

Differential Revision: D7956042

fbshipit-source-id: 221851aa311f3cdd6326497352b366048db0a1bb
This commit is contained in:
Eli White
2018-05-10 15:44:52 -07:00
committed by Facebook Github Bot
parent 266016c521
commit 8f5ebe5952
114 changed files with 1017 additions and 1035 deletions

View File

@@ -77,7 +77,7 @@ const DEBUG = false;
* allowing events such as touches to start interactions and block queued tasks
* from executing, making apps more responsive.
*/
var InteractionManager = {
const InteractionManager = {
Events: keyMirror({
interactionStart: true,
interactionComplete: true,
@@ -118,7 +118,7 @@ var InteractionManager = {
createInteractionHandle(): Handle {
DEBUG && infoLog('create interaction handle');
_scheduleUpdate();
var handle = ++_inc;
const handle = ++_inc;
_addInteractionSet.add(handle);
return handle;
},
@@ -181,14 +181,14 @@ function _scheduleUpdate() {
function _processUpdate() {
_nextUpdateHandle = 0;
var interactionCount = _interactionSet.size;
const interactionCount = _interactionSet.size;
_addInteractionSet.forEach(handle =>
_interactionSet.add(handle)
);
_deleteInteractionSet.forEach(handle =>
_interactionSet.delete(handle)
);
var nextInteractionCount = _interactionSet.size;
const nextInteractionCount = _interactionSet.size;
if (interactionCount !== 0 && nextInteractionCount === 0) {
// transition from 1+ --> 0 interactions

View File

@@ -8,14 +8,14 @@
*/
'use strict';
var InteractionManager = require('InteractionManager');
const InteractionManager = require('InteractionManager');
/**
* This mixin provides safe versions of InteractionManager start/end methods
* that ensures `clearInteractionHandle` is always called
* once per start, even if the component is unmounted.
*/
var InteractionMixin = {
const InteractionMixin = {
componentWillUnmount: function() {
while (this._interactionMixinHandles.length) {
InteractionManager.clearInteractionHandle(
@@ -27,7 +27,7 @@ var InteractionMixin = {
_interactionMixinHandles: ([]: Array<number>),
createInteractionHandle: function() {
var handle = InteractionManager.createInteractionHandle();
const handle = InteractionManager.createInteractionHandle();
this._interactionMixinHandles.push(handle);
return handle;
},

View File

@@ -11,9 +11,9 @@
jest.enableAutomock().unmock('InteractionMixin');
describe('InteractionMixin', () => {
var InteractionManager;
var InteractionMixin;
var component;
let InteractionManager;
let InteractionMixin;
let component;
beforeEach(() => {
jest.resetModules();
@@ -29,19 +29,19 @@ describe('InteractionMixin', () => {
});
it('should end interactions', () => {
var handle = {};
const handle = {};
component.clearInteractionHandle(handle);
expect(InteractionManager.clearInteractionHandle).toBeCalledWith(handle);
});
it('should schedule tasks', () => {
var task = jest.fn();
const task = jest.fn();
component.runAfterInteractions(task);
expect(InteractionManager.runAfterInteractions).toBeCalledWith(task);
});
it('should end unfinished interactions in componentWillUnmount', () => {
var handle = component.createInteractionHandle();
const handle = component.createInteractionHandle();
component.componentWillUnmount();
expect(InteractionManager.clearInteractionHandle).toBeCalledWith(handle);
});