refactor: add ScriptRunner class
Change-Id: I118adb9ec338e88b40321208b84228886bb6b590
diff --git a/src/features/Features.ts b/src/features/Features.ts
index 98a4b96..8a13700 100644
--- a/src/features/Features.ts
+++ b/src/features/Features.ts
@@ -4,6 +4,7 @@
ScriptPage,
ScriptRunPhase,
} from '../common/architecture/scripts/Script';
+import ScriptRunner from '../common/architecture/scripts/ScriptRunner';
import AutoRefreshFeature from './autoRefresh/autoRefresh.feature';
import InfiniteScrollFeature from './infiniteScroll/infiniteScroll.feature';
@@ -22,13 +23,11 @@
];
private initializedFeatures: Feature[];
- runScripts(context: Context) {
- const scripts = this.getScripts(context).sort((a, b) =>
- a.priority < b.priority ? -1 : 1,
- );
- for (const script of scripts) {
- script.execute();
- }
+ getScriptRunner(context: Context) {
+ const scripts = this.getScripts(context);
+ const scriptRunner = new ScriptRunner();
+ scriptRunner.add(...scripts);
+ return scriptRunner;
}
getScripts(context: Context) {