diff --git a/.eslintrc.json b/.eslintrc.json index aeb7f1b..a521baf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,7 @@ "root": true, "extends": ["@hug/eslint-config/recommended"], "rules": { - // Use dwdwdw and ngOnDestroy + // Use destroyRef and takeUntilDestroyed "rxjs-angular/prefer-takeuntil": "off" } } diff --git a/projects/core/src/directives/input-autosize.directive.ts b/projects/core/src/directives/input-autosize.directive.ts index c25f4e1..6a9d6a9 100644 --- a/projects/core/src/directives/input-autosize.directive.ts +++ b/projects/core/src/directives/input-autosize.directive.ts @@ -1,6 +1,5 @@ import { DestroyRef, Directive, ElementRef, inject, NgZone, OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; - import { MatInput } from '@angular/material/input'; import { debounceTime, fromEvent, mergeWith, of, startWith } from 'rxjs'; diff --git a/projects/core/src/directives/single-click.directive.ts b/projects/core/src/directives/single-click.directive.ts index 1217ae6..3edb4a3 100644 --- a/projects/core/src/directives/single-click.directive.ts +++ b/projects/core/src/directives/single-click.directive.ts @@ -1,9 +1,8 @@ import { DestroyRef, Directive, EventEmitter, HostListener, inject, Input, OnInit, Output } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ReplaySubject } from 'rxjs'; import { throttleTime } from 'rxjs/operators'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; - @Directive({ selector: '[ngx-single-click]', standalone: true diff --git a/projects/date-picker/src/datepicker-mask/datepicker-mask.directive.ts b/projects/date-picker/src/datepicker-mask/datepicker-mask.directive.ts index b0bb0a5..9eea81b 100644 --- a/projects/date-picker/src/datepicker-mask/datepicker-mask.directive.ts +++ b/projects/date-picker/src/datepicker-mask/datepicker-mask.directive.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { DestroyRef, Directive, ElementRef, forwardRef, inject, Input, OnInit, Renderer2 } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { AbstractControl, NG_VALIDATORS, NgControl } from '@angular/forms'; import { DateAdapter, MAT_DATE_FORMATS, MatDateFormats } from '@angular/material/core'; import { filterMap, KeyCodes, subscribeWith } from '@hug/ngx-core'; @@ -8,7 +9,6 @@ import { isNil } from 'lodash-es'; import { delay, EMPTY, filter, fromEvent, mergeWith, of, startWith, switchMap, tap, timeInterval } from 'rxjs'; import { NgxDatepickerMaskValidatorService } from './datepicker-mask-validator.service'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Directive({ diff --git a/projects/date-picker/src/datepicker-with-time/datepicker-with-time.component.ts b/projects/date-picker/src/datepicker-with-time/datepicker-with-time.component.ts index 1e729d2..c726056 100644 --- a/projects/date-picker/src/datepicker-with-time/datepicker-with-time.component.ts +++ b/projects/date-picker/src/datepicker-with-time/datepicker-with-time.component.ts @@ -1,5 +1,6 @@ import { TemplatePortal } from '@angular/cdk/portal'; import { AfterViewInit, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, inject, OnDestroy, TemplateRef, ViewChild, ViewContainerRef, ViewEncapsulation } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { DateAdapter } from '@angular/material/core'; import { MatDatepicker, MatDatepickerInput, MatDatepickerModule, MatDateSelectionModel } from '@angular/material/datepicker'; @@ -8,7 +9,6 @@ import { cloneDeep } from 'lodash-es'; import { delay, filter, map, tap } from 'rxjs'; import { DATE_TIME_ADAPTER, DateTimeAdapter } from '../date-adapter/date-time-adapter'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Component({ diff --git a/projects/demo-app/src/app/date-picker/date-picker-demo.component.ts b/projects/demo-app/src/app/date-picker/date-picker-demo.component.ts index 20fc683..3c0305b 100644 --- a/projects/demo-app/src/app/date-picker/date-picker-demo.component.ts +++ b/projects/demo-app/src/app/date-picker/date-picker-demo.component.ts @@ -9,6 +9,7 @@ import { AsyncPipe, DatePipe, NgIf, registerLocaleData } from '@angular/common'; import localeFrCh from '@angular/common/locales/fr-CH'; import { ChangeDetectionStrategy, Component, DestroyRef, inject, Injectable, LOCALE_ID, ViewEncapsulation } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormControl, FormGroup, ReactiveFormsModule, ValidationErrors } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; @@ -24,7 +25,6 @@ import { NgxDatepickerButtonsComponent, NgxDatepickerMaskDirective, NgxDatepicke import { addDays, addMonths, endOfMonth, startOfDay, startOfMonth } from 'date-fns'; import { frCH } from 'date-fns/locale'; import { debounceTime, ReplaySubject } from 'rxjs'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; registerLocaleData(localeFrCh); setLocale(frCH); @@ -130,7 +130,7 @@ export class DatePickerDemoComponent { public maxDate: Date; public defaultValues: DateRange; - private destroyRef = inject(DestroyRef) + private destroyRef = inject(DestroyRef); public constructor() { diff --git a/projects/snackbar/src/snackbar.component.ts b/projects/snackbar/src/snackbar.component.ts index 52218d2..563055e 100644 --- a/projects/snackbar/src/snackbar.component.ts +++ b/projects/snackbar/src/snackbar.component.ts @@ -121,6 +121,7 @@ export class NgxSnackbarComponent implements OnInit, AfterViewInit, OnDestroy { this._alignments.bottom = this._alignments.top && this._alignments.bottom ? false : this._alignments.bottom; this._alignments.left = this._alignments.right && this._alignments.left ? false : this._alignments.left; } + private destroyRef = inject(DestroyRef); /** diff --git a/projects/splitter/src/splitter.component.ts b/projects/splitter/src/splitter.component.ts index 0304a9c..074c22a 100644 --- a/projects/splitter/src/splitter.component.ts +++ b/projects/splitter/src/splitter.component.ts @@ -1,11 +1,11 @@ import { BooleanInput, coerceBooleanProperty, coerceNumberProperty, NumberInput } from '@angular/cdk/coercion'; import { NgFor, NgForOf, NgIf } from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, DestroyRef, ElementRef, EventEmitter, HostBinding, inject, Input, Output, QueryList, ViewEncapsulation } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { filter, fromEvent, map, mergeWith, of, shareReplay, Subject, switchMap, take, takeUntil, tap } from 'rxjs'; import { NgxSplitAreaDirective } from './split-area.directive'; import { NgxSplitterDirection } from './splitter-direction-type'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; interface DraggingEvent { event: MouseEvent | TouchEvent; diff --git a/projects/status/src/status.component.ts b/projects/status/src/status.component.ts index c7119a8..8152602 100644 --- a/projects/status/src/status.component.ts +++ b/projects/status/src/status.component.ts @@ -1,9 +1,9 @@ import { ChangeDetectionStrategy, Component, DestroyRef, EventEmitter, inject, Input, ViewEncapsulation } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { catchError, EMPTY, Subject, switchMap, throttleTime } from 'rxjs'; import { NgxStatus, NgxStatusAction, NgxStatusType } from './status.model'; import { NgxStatusDetailDialogService } from './status-detail/status-detail-dialog.service'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Component({ selector: 'ngx-status', diff --git a/projects/status/src/status.service.ts b/projects/status/src/status.service.ts index 57643a1..8f90a80 100644 --- a/projects/status/src/status.service.ts +++ b/projects/status/src/status.service.ts @@ -1,10 +1,10 @@ import { DOCUMENT } from '@angular/common'; import { ApplicationRef, ComponentFactoryResolver, DestroyRef, EmbeddedViewRef, inject, Injectable, Injector } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { NgxLazyLoaderService } from '@hug/ngx-core'; import { mergeWith, switchMap, take, tap, timer } from 'rxjs'; import { NgxStatus, NgxStatusAction } from './status.model'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; const durationLong = 30_000; diff --git a/projects/tooltip/src/tooltip.directive.ts b/projects/tooltip/src/tooltip.directive.ts index e69393d..b3c7926 100644 --- a/projects/tooltip/src/tooltip.directive.ts +++ b/projects/tooltip/src/tooltip.directive.ts @@ -13,7 +13,7 @@ export class NgxTooltipDirective { @Input('ngx-tooltip') public openTooltip$?: (element: HTMLElement) => Observable; private elementRef = inject>(ElementRef); - private destroyRef = inject(DestroyRef) + private destroyRef = inject(DestroyRef); public constructor() {