blob: b4c07a57ecd9ae6b6dcb6d5c2bbb961d286cf841 [file] [log] [blame]
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02001import NodeWatcherSingleton from '../../../nodeWatcher/NodeWatcher';
2import { ConcreteNodeWatcherScriptHandler } from './handlers/NodeWatcherScriptHandler';
3import Script from '../Script';
4
Adrià Vilanova Martínez8b591d92024-10-19 15:55:15 +02005/**
6 * @deprecated
7 */
8export default abstract class LegacyNodeWatcherScript<Options> extends Script {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02009 public abstract handlers: Map<
10 string,
11 ConcreteNodeWatcherScriptHandler<Options>
12 >;
13
14 /**
15 * Resolves to the options when the script is executed.
16 *
17 * This is so we can defer retrieving dependencies until the script is
18 * executed, to prevent loading unnecessary things if they aren't needed
19 * after all.
20 */
21 protected abstract optionsFactory(): Options;
22
23 execute() {
24 const nodeWatcher = NodeWatcherSingleton.getInstance();
25 const options = this.optionsFactory();
26
27 for (const [key, handlerClass] of this.handlers) {
28 const handler = new handlerClass(options);
29 nodeWatcher.setHandler(key, handler);
30 }
31 }
32}