@@ -25,7 +25,7 @@ import {
25
25
afterNextRender ,
26
26
AfterRenderPhase
27
27
} from '@angular/core' ;
28
- import { EMPTY , Subject , Subscription , fromEvent , interval , merge , timer } from 'rxjs' ;
28
+ import { EMPTY , Subject , fromEvent , interval , merge , timer } from 'rxjs' ;
29
29
import { debounceTime , filter , map , startWith , switchMap , takeUntil } from 'rxjs/operators' ;
30
30
31
31
import { IS_BROWSER } from '../symbols' ;
@@ -80,24 +80,24 @@ export class NguCarousel<T, U extends NgIterable<T> = NgIterable<T>>
80
80
readonly activePoint = signal ( 0 ) ;
81
81
readonly pointNumbers = signal < number [ ] > ( [ ] ) ;
82
82
83
- inputs = input . required < NguCarouselConfig > ( ) ;
84
- carouselLoad = output < number > ( ) ;
85
- onMove = output < this> ( ) ;
83
+ readonly inputs = input . required < NguCarouselConfig > ( ) ;
84
+ readonly carouselLoad = output < number > ( ) ;
85
+ readonly onMove = output < this> ( ) ;
86
86
87
87
private _defDirectives = contentChildren ( NguCarouselDefDirective ) ;
88
88
89
89
private _nodeOutlet = viewChild . required ( NguCarouselOutlet ) ;
90
90
91
- nextButton = contentChild ( NguCarouselNextDirective , { read : ElementRef } ) ;
92
- prevButton = contentChild ( NguCarouselPrevDirective , { read : ElementRef } ) ;
91
+ readonly nextButton = contentChild ( NguCarouselNextDirective , { read : ElementRef } ) ;
92
+ readonly prevButton = contentChild ( NguCarouselPrevDirective , { read : ElementRef } ) ;
93
93
94
- carouselMain1 = viewChild . required ( 'ngucarousel' , { read : ElementRef } ) ;
95
- _nguItemsContainer = viewChild . required ( 'nguItemsContainer' , { read : ElementRef } ) ;
96
- _touchContainer = viewChild . required ( 'touchContainer' , { read : ElementRef } ) ;
94
+ readonly carouselMain1 = viewChild . required ( 'ngucarousel' , { read : ElementRef } ) ;
95
+ readonly _nguItemsContainer = viewChild . required ( 'nguItemsContainer' , { read : ElementRef } ) ;
96
+ readonly _touchContainer = viewChild . required ( 'touchContainer' , { read : ElementRef } ) ;
97
97
98
98
private _arrayChanges : IterableChanges < T > | null = null ;
99
99
100
- dataSource = input . required ( {
100
+ readonly dataSource = input . required ( {
101
101
transform : ( v : NguCarouselDataSource < T , U > ) => v || ( [ ] as never )
102
102
} ) ;
103
103
@@ -125,8 +125,8 @@ export class NguCarousel<T, U extends NgIterable<T> = NgIterable<T>>
125
125
* relative to the function to know if a Items should be added/removed/moved.
126
126
* Accepts a function that takes two parameters, `index` and `item`.
127
127
*/
128
- trackBy = input < TrackByFunction < T > > ( ) ;
129
- _trackByFn = computed ( ( ) => {
128
+ readonly trackBy = input < TrackByFunction < T > > ( ) ;
129
+ readonly _trackByFn = computed ( ( ) => {
130
130
const fn = this . trackBy ( ) ;
131
131
if ( NG_DEV_MODE && fn != null && typeof fn !== 'function' && console ?. warn ) {
132
132
console . warn ( `trackBy must be a function, but received ${ JSON . stringify ( fn ) } .` ) ;
@@ -165,27 +165,26 @@ export class NguCarousel<T, U extends NgIterable<T> = NgIterable<T>>
165
165
{ allowSignalWrites : true }
166
166
) ;
167
167
168
- let preSub : Subscription ;
169
- effect ( ( ) => {
170
- preSub ?. unsubscribe ( ) ;
168
+ effect ( cleanup => {
171
169
const prevButton = this . prevButton ( ) ;
172
170
untracked ( ( ) => {
173
171
if ( prevButton ) {
174
- preSub = fromEvent ( prevButton . nativeElement , 'click' )
172
+ const preSub = fromEvent ( prevButton . nativeElement , 'click' )
175
173
. pipe ( takeUntil ( this . _destroy$ ) )
176
174
. subscribe ( ( ) => this . _carouselScrollOne ( 0 ) ) ;
175
+ cleanup ( ( ) => preSub . unsubscribe ( ) ) ;
177
176
}
178
177
} ) ;
179
178
} ) ;
180
- let nextSub : Subscription ;
181
- effect ( ( ) => {
182
- nextSub ?. unsubscribe ( ) ;
179
+
180
+ effect ( cleanup => {
183
181
const nextButton = this . nextButton ( ) ;
184
182
untracked ( ( ) => {
185
183
if ( nextButton ) {
186
- nextSub = fromEvent ( nextButton . nativeElement , 'click' )
184
+ const nextSub = fromEvent ( nextButton . nativeElement , 'click' )
187
185
. pipe ( takeUntil ( this . _destroy$ ) )
188
186
. subscribe ( ( ) => this . _carouselScrollOne ( 1 ) ) ;
187
+ cleanup ( ( ) => nextSub . unsubscribe ( ) ) ;
189
188
}
190
189
} ) ;
191
190
} ) ;
0 commit comments