Skip to content

Commit

Permalink
Feat: add new outputs to form: (modelValueChange) and (validityChange)
Browse files Browse the repository at this point in the history
  • Loading branch information
navix committed Jan 6, 2023
1 parent dc5dae8 commit 874fb0f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions projects/ngfe/src/lib/core/fe-form.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
ChangeDetectorRef,
Directive,
Directive, EventEmitter,
HostBinding,
Input,
NgZone,
OnChanges,
OnDestroy,
OnDestroy, Output,
SimpleChanges,
} from '@angular/core';
import { ReplaySubject, Subject, Subscription, take } from 'rxjs';
Expand All @@ -28,14 +28,18 @@ export class FeForm implements OnChanges, OnDestroy {
private _modelValueChange$ = new Subject<undefined>();
readonly change$ = this._modelValueChange$.pipe(
debounceTime(0),
map(() => undefined),
);
@Output() modelValueChange = new EventEmitter<undefined>();

private _validityCheck$ = new ReplaySubject<undefined>(1);
readonly validity$ = this._validityCheck$.pipe(
debounceTime(0),
map(() => this.validity),
distinctUntilChanged(),
);
@Output() validityChange = new EventEmitter<FeValidity>();

readonly valid$ = this._validityCheck$.pipe(
debounceTime(0),
map(() => this.valid),
Expand All @@ -59,6 +63,8 @@ export class FeForm implements OnChanges, OnDestroy {
this._validityCheck$.subscribe(() => {
this.cdr.markForCheck();
});
this.change$.subscribe(this.modelValueChange);
this.validity$.subscribe(this.validityChange);
}

ngOnChanges(changes: SimpleChanges) {
Expand Down

0 comments on commit 874fb0f

Please sign in to comment.