I'm trying to send this request using debounceTime method, to not send multiple times to server. but is not working. This service is being called instantly.
On drag'n'drop drop event I want to save positions with saveWidgetsPosition func.
drop(event: CdkDragDrop<string[]>) {
if (event.previousContainer !== event.container) {
transferArrayItem(event.previousContainer.data, event.container.data, event.previousIndex, event.currentIndex);
} else {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
}
this.saveWidgetsPosition(this.columns);
}
Function to save positions
saveWidgetsPosition(columns: any[]) {
const columnsLabels = columns.map(x => x.map(y => y.label));
this.userService.saveWidgetsPosition({ user: this.user, columns: columnsLabels})
.pipe(debounceTime(5000))
.subscribe(res => console.log(res));
}