Skip to content

Commit 0e35a6c

Browse files
committed
refactor: optional chaining ?. for emits
1 parent 6c7bfae commit 0e35a6c

File tree

11 files changed

+12
-12
lines changed

11 files changed

+12
-12
lines changed

projects/coreui-angular/src/lib/alert/alert.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class AlertComponent {
109109
set visible(value: boolean) {
110110
if (this.#visible() !== value) {
111111
this.#visible.set(value);
112-
this.visibleChange.emit(value);
112+
this.visibleChange?.emit(value);
113113
}
114114
}
115115

projects/coreui-angular/src/lib/carousel/carousel/carousel.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
213213
private carouselStateSubscribe(): void {
214214
this.#carouselService.carouselIndex$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((nextItem) => {
215215
if ('active' in nextItem && typeof nextItem.active === 'number') {
216-
this.itemChange.emit(nextItem.active);
216+
this.itemChange?.emit(nextItem.active);
217217
}
218218
this.activeItemInterval =
219219
typeof nextItem.interval === 'number' && nextItem.interval > -1 ? nextItem.interval : this.interval();

projects/coreui-angular/src/lib/dropdown/dropdown/dropdown.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class DropdownComponent implements OnDestroy, OnInit {
243243
this.activeTrap = visible;
244244
visible ? this.createPopperInstance() : this.destroyPopperInstance();
245245
this.setVisibleState(visible);
246-
this.visibleChange.emit(visible);
246+
this.visibleChange?.emit(visible);
247247
});
248248

249249
readonly visibleChange = output<boolean>();

projects/coreui-angular/src/lib/modal/modal/modal.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class ModalComponent implements OnInit, OnDestroy, AfterViewInit {
165165
this.#visible.set(value);
166166
this.setBodyStyles(value);
167167
this.setBackdrop(this.backdrop() !== false && value);
168-
this.visibleChange.emit(value);
168+
this.visibleChange?.emit(value);
169169
}
170170
}
171171

projects/coreui-angular/src/lib/offcanvas/offcanvas/offcanvas.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class OffcanvasComponent implements OnInit, OnDestroy {
153153
this.setBackdrop(false);
154154
}
155155
this.layoutChangeSubscribe(visible);
156-
this.visibleChange.emit(visible);
156+
this.visibleChange?.emit(visible);
157157
});
158158

159159
/**

projects/coreui-angular/src/lib/sidebar/sidebar-nav/sidebar-nav-link.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class SidebarNavLinkComponent implements OnInit, OnDestroy {
111111
}
112112

113113
linkClicked(): void {
114-
this.linkClick.emit();
114+
this.linkClick?.emit();
115115
}
116116

117117
// public hideMobile() {

projects/coreui-angular/src/lib/sidebar/sidebar/sidebar.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
129129
readonly #visible = linkedSignal(this.visibleInput);
130130

131131
readonly #visibleEffect = effect(() => {
132-
this.visibleChange.emit(this.#visible());
132+
this.visibleChange?.emit(this.#visible());
133133
});
134134

135135
set visible(value: boolean) {

projects/coreui-angular/src/lib/tabs-2/tab-panel/tab-panel.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class TabPanelComponent {
9696

9797
readonly visible = computed(() => {
9898
const visible = this.tabsService.activeItemKey() === this.itemKey() && !this.tabsService.activeItem()?.disabled;
99-
this.visibleChange.emit({ itemKey: this.itemKey(), visible });
99+
this.visibleChange?.emit({ itemKey: this.itemKey(), visible });
100100
return visible;
101101
});
102102

projects/coreui-angular/src/lib/tabs/tab-content/tab-content.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class TabContentComponent implements AfterContentChecked, AfterContentIni
4141
const newValue = value;
4242
if (this.#activeTabPaneIdx != newValue) {
4343
this.#activeTabPaneIdx = newValue;
44-
this.activeTabPaneIdxChange.emit(newValue);
44+
this.activeTabPaneIdxChange?.emit(newValue);
4545
this.#changeDetectorRef.markForCheck();
4646
this.#changeDetectorRef.detectChanges();
4747
}

projects/coreui-angular/src/lib/toast/toast/toast.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class ToastComponent implements OnInit, OnDestroy {
107107
if (this.#visible !== newValue) {
108108
this.#visible = newValue;
109109
newValue ? this.setTimer() : this.clearTimer();
110-
this.visibleChange.emit(newValue);
110+
this.visibleChange?.emit(newValue);
111111
this.changeDetectorRef.markForCheck();
112112
}
113113
}
@@ -147,7 +147,7 @@ export class ToastComponent implements OnInit, OnDestroy {
147147

148148
set clock(value) {
149149
this._clock = value;
150-
this.timer.emit(this._clock);
150+
this.timer?.emit(this._clock);
151151
this.changeDetectorRef.markForCheck();
152152
}
153153

0 commit comments

Comments
 (0)