Skip to content

Commit 874fb0f

Browse files
committed
Feat: add new outputs to form: (modelValueChange) and (validityChange)
1 parent dc5dae8 commit 874fb0f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

projects/ngfe/src/lib/core/fe-form.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
ChangeDetectorRef,
3-
Directive,
3+
Directive, EventEmitter,
44
HostBinding,
55
Input,
66
NgZone,
77
OnChanges,
8-
OnDestroy,
8+
OnDestroy, Output,
99
SimpleChanges,
1010
} from '@angular/core';
1111
import { ReplaySubject, Subject, Subscription, take } from 'rxjs';
@@ -28,14 +28,18 @@ export class FeForm implements OnChanges, OnDestroy {
2828
private _modelValueChange$ = new Subject<undefined>();
2929
readonly change$ = this._modelValueChange$.pipe(
3030
debounceTime(0),
31+
map(() => undefined),
3132
);
33+
@Output() modelValueChange = new EventEmitter<undefined>();
3234

3335
private _validityCheck$ = new ReplaySubject<undefined>(1);
3436
readonly validity$ = this._validityCheck$.pipe(
3537
debounceTime(0),
3638
map(() => this.validity),
3739
distinctUntilChanged(),
3840
);
41+
@Output() validityChange = new EventEmitter<FeValidity>();
42+
3943
readonly valid$ = this._validityCheck$.pipe(
4044
debounceTime(0),
4145
map(() => this.valid),
@@ -59,6 +63,8 @@ export class FeForm implements OnChanges, OnDestroy {
5963
this._validityCheck$.subscribe(() => {
6064
this.cdr.markForCheck();
6165
});
66+
this.change$.subscribe(this.modelValueChange);
67+
this.validity$.subscribe(this.validityChange);
6268
}
6369

6470
ngOnChanges(changes: SimpleChanges) {

0 commit comments

Comments
 (0)