From e05d3d8d2538e83130d29da40d9326e93829bb57 Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Sat, 14 Mar 2026 01:05:25 +0700 Subject: [PATCH] feat(lib): replace ngOnChanges with effect --- libs/ui/src/lib/toggle/toggle.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/ui/src/lib/toggle/toggle.component.ts b/libs/ui/src/lib/toggle/toggle.component.ts index b376dd1c0..f5272f9bd 100644 --- a/libs/ui/src/lib/toggle/toggle.component.ts +++ b/libs/ui/src/lib/toggle/toggle.component.ts @@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, - OnChanges, + effect, input, output } from '@angular/core'; @@ -18,7 +18,7 @@ import { MatRadioModule } from '@angular/material/radio'; styleUrls: ['./toggle.component.scss'], templateUrl: './toggle.component.html' }) -export class GfToggleComponent implements OnChanges { +export class GfToggleComponent { public readonly defaultValue = input.required(); public readonly isLoading = input(false); public readonly options = input([]); @@ -26,8 +26,10 @@ export class GfToggleComponent implements OnChanges { protected readonly optionFormControl = new FormControl(null); protected readonly valueChange = output>(); - public ngOnChanges() { - this.optionFormControl.setValue(this.defaultValue()); + constructor() { + effect(() => { + this.optionFormControl.setValue(this.defaultValue()); + }); } public onValueChange() {