Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Ultraviolet
Path: blob/main/src/client/hook.js
304 views
1
/**
2
*
3
* @template Data
4
* @template Target
5
* @template That
6
* @property {Data} data
7
* @property {Target} target
8
* @property {That} that
9
*/
10
class HookEvent {
11
#intercepted;
12
#returnValue;
13
/**
14
*
15
* @param {Data} data
16
* @param {Target} target
17
* @param {That} that
18
*/
19
constructor(data = {}, target = null, that = null) {
20
this.#intercepted = false;
21
this.#returnValue = null;
22
/**
23
* @type {Data}
24
*/
25
this.data = data;
26
/**
27
* @type {Target}
28
*/
29
this.target = target;
30
/**
31
* @type {That}
32
*/
33
this.that = that;
34
}
35
get intercepted() {
36
return this.#intercepted;
37
}
38
get returnValue() {
39
return this.#returnValue;
40
}
41
respondWith(input) {
42
this.#returnValue = input;
43
this.#intercepted = true;
44
}
45
}
46
47
export default HookEvent;
48
49