Skip to content

Commit 1bb33e6

Browse files
authored
Merge pull request #25 from Nitro-Bolt/variable-manager
added RUNTIME_STEP_START and RUNTIME_STEP_STOP events (Variable Manager VM part)
2 parents 72a2445 + 5d2c6a3 commit 1bb33e6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/engine/runtime.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,22 @@ class Runtime extends EventEmitter {
919919
return 'RUNTIME_DISPOSED';
920920
}
921921

922+
/**
923+
* Event name when _step() has been called.
924+
* @const {string}
925+
*/
926+
static get RUNTIME_STEP_START () {
927+
return 'RUNTIME_STEP_START';
928+
}
929+
930+
/**
931+
* Event name when _step() has finished all processing within the function.
932+
* @const {string}
933+
*/
934+
static get RUNTIME_STEP_END () {
935+
return 'RUNTIME_STEP_END';
936+
}
937+
922938
/**
923939
* Event name for reporting that a block was updated and needs to be rerendered.
924940
* @const {string}
@@ -2581,6 +2597,11 @@ class Runtime extends EventEmitter {
25812597
* inactive threads after each iteration.
25822598
*/
25832599
_step () {
2600+
// RUNTIME_STEP_START runs before BEFORE_EXECUTE
2601+
// this runs before any processing of this new step
2602+
this.frameLoop._stepCounter++;
2603+
this.emit(Runtime.RUNTIME_STEP_START);
2604+
25842605
if (this.interpolationEnabled) {
25852606
interpolate.setupInitialState(this);
25862607
}
@@ -2664,6 +2685,9 @@ class Runtime extends EventEmitter {
26642685
if (this.interpolationEnabled) {
26652686
this._lastStepTime = Date.now();
26662687
}
2688+
2689+
// RUNTIME_STEP_END runs after AFTER_EXECUTE
2690+
this.emit(Runtime.RUNTIME_STEP_END);
26672691
}
26682692

26692693
/**

0 commit comments

Comments
 (0)