I have a complex calculator app written in Angular6 which calculates the results based of several inputs in the ngModelChange event and to show these results in charts direc
I solved this for now with help of this question: debounceTime & distinctUntilChanged in angular 6
So I created a Viewchild for Every Input and placed them in an array. And in the ngAfterViewInit I call this method:
setInputEvent() {
let inputArray = this.fillViewChildsInArray();
for (let element of inputArray) {
this.input$ = fromEvent(element.nativeElement, 'input')
.pipe(
debounceTime(1000),
map((e: KeyboardEvent) => e.target['value'])
);
this.input$.subscribe((val: string) => {
this.calculate();
});
}
}