@@ -13,15 +13,15 @@ type SignalMap<K> = {
13
13
* @example
14
14
* ```ts
15
15
* const Signals = imports.signals;
16
- *
16
+ *
17
17
* // Define an interface with the same name of your class to make the methods known
18
18
* interface Events extends Signals.Methods {}
19
- *
19
+ *
20
20
* class Events {}
21
21
* Signals.addSignalMethods(Events.prototype);
22
- *
22
+ *
23
23
* const events = new Events();
24
- *
24
+ *
25
25
* // Typescript will not complain here
26
26
* events.emit("test-signal", "test argument");
27
27
* ```
@@ -30,21 +30,21 @@ export interface SignalMethods<S extends SignalMap<S> = any> {
30
30
/**
31
31
* Connects a callback to a signal for an object. Pass the returned ID to
32
32
* `disconnect()` to remove the handler.
33
- *
33
+ *
34
34
* If `callback` returns `true`, emission will stop and no other handlers will be
35
35
* invoked.
36
- *
36
+ *
37
37
* > Warning: Unlike GObject signals, `this` within a signal callback will always
38
38
* > refer to the global object (ie. `globalThis`).
39
- *
39
+ *
40
40
* @param sigName A signal name
41
41
* @param callback A callback function
42
42
* @returns A handler ID
43
43
*/
44
44
connect < Name extends keyof S > ( sigName : Name , callback : ( self : this, ...args : S [ Name ] ) => boolean | undefined ) : number ;
45
45
/**
46
46
* Emits a signal for an object. Emission stops if a signal handler returns `true`.
47
- *
47
+ *
48
48
* Unlike GObject signals, it is not necessary to declare signals or define their
49
49
* signature. Simply call `emit()` with whatever signal name you wish, with
50
50
* whatever arguments you wish.
@@ -71,6 +71,9 @@ export interface SignalMethods<S extends SignalMap<S> = any> {
71
71
72
72
export interface EventEmitter < S extends SignalMap < S > = any > extends SignalMethods < S > { }
73
73
74
+ /**
75
+ * @version 46
76
+ */
74
77
export class EventEmitter < S extends SignalMap < S > = any > {
75
78
connectObject ( ...args : any [ ] ) : number // TODO: return type is return type of imports.misc.signalTracker.connectObject
76
79
@@ -79,4 +82,4 @@ export class EventEmitter<S extends SignalMap<S> = any> {
79
82
connect_object ( ...args : any [ ] ) : ReturnType < typeof this . connectObject >
80
83
81
84
disconnect_object ( ...args : any [ ] ) : ReturnType < typeof this . disconnectObject >
82
- }
85
+ }
0 commit comments