-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvcsCallback.js
61 lines (53 loc) · 1.2 KB
/
vcsCallback.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { ClassRegistry } from '@vcmap/core';
/**
* @type {ClassRegistry<typeof VcsCallback>}
*/
export const callbackClassRegistry = new ClassRegistry();
/**
* creates instances of VcsCallback classes and executes its callback function
* @param {import("@src/vcsUiApp.js").default} app
* @param {Array<VcsCallbackOptions>} vcsCallbackOptions
*/
export function executeCallbacks(app, vcsCallbackOptions) {
vcsCallbackOptions.forEach((options) =>
app.callbackClassRegistry.createFromTypeOptions(options, app)?.callback(),
);
}
/**
* @typedef {Object} VcsCallbackOptions
* @property {string} type
*/
/**
* @class
* @abstract
*/
class VcsCallback {
/**
* @type {string}
*/
static get className() {
return 'VcsCallback';
}
/**
* @param {VcsCallbackOptions} options
* @param {import("@src/vcsUiApp.js").default} app
*/
constructor(options, app) {
/**
* @protected
* @type {import("@src/vcsUiApp.js").default}
*/
this._app = app;
}
// eslint-disable-next-line class-methods-use-this
callback() {}
/**
* @returns {VcsCallbackOptions}
*/
toJSON() {
return {
type: this.constructor.className,
};
}
}
export default VcsCallback;