From 46779250c20d6d3e2da5938cb36277de49f55143 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 7 Sep 2018 19:58:46 -0400 Subject: [PATCH] refactor to use .bind --- src/app/debugger/debuggerUI.js | 4 +- src/app/debugger/debuggerUI/StepManager.js | 57 ++++++---------------- 2 files changed, 17 insertions(+), 44 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index c286cd613d..a2524910b2 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -34,7 +34,7 @@ class DebuggerUI { }) this.transactionDebugger.event.register('breakpointStep', function (step) { - self.stepManager.step_manager.jumpTo(step) + self.stepManager.stepManager.jumpTo(step) }) this.debugger_ui.event.register('indexChanged', function (index) { @@ -106,7 +106,7 @@ class DebuggerUI { if (!shouldOpenDebugger) return this.transactionDebugger.step_manager = new StepManager(this.debugger_ui, this.transactionDebugger.debugger.traceManager) - this.stepManager = new StepManagerUI(this.transactionDebugger) + this.stepManager = new StepManagerUI(this.transactionDebugger.step_manager) this.stepManager.event.register('stepChanged', this, function (stepIndex) { self.debugger_ui.stepChanged(stepIndex) }) diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index 42febd9e5e..5d99ba79f3 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -5,9 +5,9 @@ var yo = require('yo-yo') var ButtonNavigator = require('./ButtonNavigator') var Slider = require('./Slider') -function StepManager (_debugger) { +function StepManager (stepManager) { this.event = new EventManager() - this.step_manager = _debugger.step_manager + this.stepManager = stepManager this.startSlider() this.startButtonNavigator() } @@ -16,52 +16,25 @@ StepManager.prototype.startSlider = function () { const self = this this.slider = new Slider() - this.slider.event.register('sliderMoved', (step) => { - self.step_manager.jumpTo(step) - }) - this.step_manager.event.register('traceLengthChanged', (length) => { - self.slider.setSliderLength(length) - }) + this.slider.event.register('sliderMoved', self.stepManager.jumpTo.bind(this.stepManager)) + this.stepManager.event.register('traceLengthChanged', self.slider.setSliderLength.bind(this.slider)) } StepManager.prototype.startButtonNavigator = function () { const self = this this.buttonNavigator = new ButtonNavigator() - this.step_manager.event.register('revertWarning', (revertedReason) => { - if (self.buttonNavigator) { - self.buttonNavigator.resetWarning(revertedReason) - } - }) - - this.buttonNavigator.event.register('stepIntoBack', this, function () { - self.step_manager.stepIntoBack() - }) - this.buttonNavigator.event.register('stepIntoForward', this, function () { - self.step_manager.stepIntoForward() - }) - this.buttonNavigator.event.register('stepOverBack', this, function () { - self.step_manager.stepOverBack() - }) - this.buttonNavigator.event.register('stepOverForward', this, function () { - self.step_manager.stepOverForward() - }) - this.buttonNavigator.event.register('jumpOut', this, function () { - self.step_manager.jumpOut() - }) - this.buttonNavigator.event.register('jumpToException', this, function () { - self.step_manager.jumpToException() - }) - this.buttonNavigator.event.register('jumpNextBreakpoint', (exceptionIndex) => { - self.step_manager.jumpNextBreakpoint() - }) - this.buttonNavigator.event.register('jumpPreviousBreakpoint', (exceptionIndex) => { - self.step_manager.jumpPreviousBreakpoint() - }) - - this.step_manager.event.register('stepChanged', (step, stepState, jumpOutDisabled) => { - self.updateStep(step, stepState, jumpOutDisabled) - }) + this.stepManager.event.register('revertWarning', self.buttonNavigator.resetWarning.bind(this.buttonNavigator)) + this.stepManager.event.register('stepChanged', self.updateStep.bind(this)) + + this.buttonNavigator.event.register('stepIntoBack', self.stepManager.stepIntoBack.bind(this.stepManager)) + this.buttonNavigator.event.register('stepIntoForward', self.stepManager.stepIntoForward.bind(this.stepManager)) + this.buttonNavigator.event.register('stepOverBack', self.stepManager.stepOverBack.bind(this.stepManager)) + this.buttonNavigator.event.register('stepOverForward', self.stepManager.stepOverForward.bind(this.stepManager)) + this.buttonNavigator.event.register('jumpOut', self.stepManager.jumpOut.bind(this.stepManager)) + this.buttonNavigator.event.register('jumpToException', self.stepManager.jumpToException.bind(this.stepManager)) + this.buttonNavigator.event.register('jumpNextBreakpoint', self.stepManager.jumpNextBreakpoint.bind(this.stepManager)) + this.buttonNavigator.event.register('jumpPreviousBreakpoint', self.stepManager.jumpPreviousBreakpoint.bind(this.stepManager)) } StepManager.prototype.updateStep = function (step, stepState, jumpOutDisabled) {