Skip to content

Commit 5d2c6a3

Browse files
committed
added RUNTIME_STEP_START and RUNTIME_STEP_STOP events
1 parent 44c475f commit 5d2c6a3

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}
@@ -2563,6 +2579,11 @@ class Runtime extends EventEmitter {
25632579
* inactive threads after each iteration.
25642580
*/
25652581
_step () {
2582+
// RUNTIME_STEP_START runs before BEFORE_EXECUTE
2583+
// this runs before any processing of this new step
2584+
this.frameLoop._stepCounter++;
2585+
this.emit(Runtime.RUNTIME_STEP_START);
2586+
25662587
if (this.interpolationEnabled) {
25672588
interpolate.setupInitialState(this);
25682589
}
@@ -2646,6 +2667,9 @@ class Runtime extends EventEmitter {
26462667
if (this.interpolationEnabled) {
26472668
this._lastStepTime = Date.now();
26482669
}
2670+
2671+
// RUNTIME_STEP_END runs after AFTER_EXECUTE
2672+
this.emit(Runtime.RUNTIME_STEP_END);
26492673
}
26502674

26512675
/**

0 commit comments

Comments
 (0)