refactor: migrate infinite scroll feature to a new architecture
This CL introduces a new architecture for the features source code.
Bug: twpowertools:176
Change-Id: I9abc4df2fb67f9bb0c9114aaffc6916d34f1b7ff
diff --git a/src/common/architecture/features/Feature.ts b/src/common/architecture/features/Feature.ts
new file mode 100644
index 0000000..c14c338
--- /dev/null
+++ b/src/common/architecture/features/Feature.ts
@@ -0,0 +1,29 @@
+import Script, { ConcreteScript } from '../scripts/Script';
+
+export default abstract class Feature {
+ /**
+ * Internal codename used for the feature.
+ *
+ * It will be used for i18n translations, shown in log messages, etc.
+ */
+ abstract readonly codename: string;
+
+ /**
+ * Options which control the behavior of this feature.
+ */
+ abstract readonly relatedOptions: string[];
+
+ /**
+ * Uninitialized scripts which are associated with the feature.
+ */
+ abstract readonly scripts: ConcreteScript[];
+
+ private initializedScripts: Script[];
+
+ public getScripts() {
+ if (this.initializedScripts === undefined) {
+ this.initializedScripts = this.scripts.map((script) => new script());
+ }
+ return this.initializedScripts;
+ }
+}