Skip to content

Commit e6e04d2

Browse files
committed
refactor(toast): migrate visible to linkedSignal
1 parent 804218e commit e6e04d2

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ElementRef,
88
inject,
99
input,
10+
linkedSignal,
1011
numberAttribute,
1112
OnDestroy,
1213
OnInit,
@@ -98,26 +99,23 @@ export class ToastComponent implements OnInit, OnDestroy {
9899
*/
99100
readonly visibleInput = input(false, { transform: booleanAttribute, alias: 'visible' });
100101

101-
readonly #visibleInputEffect = effect(() => {
102-
this.visible = this.visibleInput();
102+
readonly #visible = linkedSignal(this.visibleInput);
103+
104+
readonly #visibleEffect = effect(() => {
105+
const newValue = this.#visible();
106+
newValue ? this.setTimer() : this.clearTimer();
107+
this.visibleChange?.emit(newValue);
108+
this.changeDetectorRef.markForCheck();
103109
});
104110

105111
set visible(value: boolean) {
106-
const newValue = value;
107-
if (this.#visible !== newValue) {
108-
this.#visible = newValue;
109-
newValue ? this.setTimer() : this.clearTimer();
110-
this.visibleChange?.emit(newValue);
111-
this.changeDetectorRef.markForCheck();
112-
}
112+
this.#visible.set(value);
113113
}
114114

115-
get visible() {
116-
return this.#visible;
115+
get visible(): boolean {
116+
return this.#visible();
117117
}
118118

119-
#visible = false;
120-
121119
/**
122120
* @ignore
123121
*/

0 commit comments

Comments
 (0)