File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
2
computed ,
3
+ DestroyRef ,
3
4
inject ,
4
5
Injectable ,
5
6
Injector ,
6
7
isSignal ,
7
- OnDestroy ,
8
8
Signal ,
9
9
} from '@angular/core' ;
10
10
import { toSignal } from '@angular/core/rxjs-interop' ;
@@ -75,9 +75,8 @@ export type ReadOnly = 'get' | 'select' | 'computed' | 'signal';
75
75
* @docsPage RxState
76
76
*/
77
77
@Injectable ( )
78
- export class RxState < State extends object >
79
- implements OnDestroy , Subscribable < State >
80
- {
78
+ export class RxState < State extends object > implements Subscribable < State > {
79
+ private readonly destroyRef = inject ( DestroyRef ) ;
81
80
private subscription = new Subscription ( ) ;
82
81
83
82
protected scheduler = inject ( RX_STATE_SCHEDULER , { optional : true } ) ;
@@ -109,6 +108,8 @@ export class RxState<State extends object>
109
108
*/
110
109
constructor ( ) {
111
110
this . subscription . add ( this . subscribe ( ) ) ;
111
+
112
+ this . destroyRef . onDestroy ( ( ) => this . ngOnDestroy ( ) ) ;
112
113
}
113
114
114
115
/**
You can’t perform that action at this time.
0 commit comments