File tree 3 files changed +16
-6
lines changed
3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -448,8 +448,9 @@ export class Thread extends WithSubscriptions {
448
448
} ;
449
449
450
450
public unregisterSubscriptions = ( ) => {
451
- super . unregisterSubscriptions ( ) ;
451
+ const symbol = super . unregisterSubscriptions ( ) ;
452
452
this . state . partialNext ( { isStateStale : true } ) ;
453
+ return symbol ;
453
454
} ;
454
455
455
456
public deleteReplyLocally = ( { message } : { message : MessageResponse } ) => {
Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ export class ThreadManager extends WithSubscriptions {
219
219
this . state
220
220
. getLatestValue ( )
221
221
. threads . forEach ( ( thread ) => thread . unregisterSubscriptions ( ) ) ;
222
- super . unregisterSubscriptions ( ) ;
222
+ return super . unregisterSubscriptions ( ) ;
223
223
} ;
224
224
225
225
public reload = async ( { force = false } = { } ) => {
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ import type { Unsubscribe } from '../store';
6
6
*/
7
7
export abstract class WithSubscriptions {
8
8
private unsubscribeFunctions : Set < Unsubscribe > = new Set ( ) ;
9
+ /**
10
+ * Workaround for the missing TS keyword - ensures that inheritants
11
+ * overriding `unregisterSubscriptions` call the base method and return
12
+ * its unique symbol value.
13
+ */
14
+ private static symbol = Symbol ( WithSubscriptions . name ) ;
9
15
10
16
public abstract registerSubscriptions ( ) : void ;
11
17
@@ -25,18 +31,21 @@ export abstract class WithSubscriptions {
25
31
* If you re-declare `unregisterSubscriptions` method within your class
26
32
* make sure to run the original too.
27
33
*
28
- * @example
34
+ * @example
29
35
* ```ts
30
- * class T {
36
+ * class T extends WithSubscriptions {
37
+ * ...
31
38
* public unregisterSubscriptions = () => {
32
- * super.unregisterSubscriptions();
33
39
* this.customThing();
40
+ * return super.unregisterSubscriptions();
34
41
* }
35
42
* }
36
43
* ```
37
44
*/
38
- public unregisterSubscriptions ( ) {
45
+ public unregisterSubscriptions ( ) : typeof WithSubscriptions . symbol {
39
46
this . unsubscribeFunctions . forEach ( ( unsubscribe ) => unsubscribe ( ) ) ;
40
47
this . unsubscribeFunctions . clear ( ) ;
48
+
49
+ return WithSubscriptions . symbol ;
41
50
}
42
51
}
You can’t perform that action at this time.
0 commit comments