You just need to subscribe to formFieldValueChanged, and save the form using formService.saveTaskForm whenever there is a change on the form values.
Important Note: Make sure you unsubscribe from autosave subscription onDestroy, to avoid messing and overriding previous accessed forms/tasks.
import {FormEvent, FormService} from "@alfresco/adf-core";
import {debounceTime} from "rxjs/operators";
import {Component, Input} from "@angular/core";
@Component({template: ''})
export abstract class FormApsAbstractComponent implements OnDestroy {
@Input() taskId: string;
autoSaveSubscription: Subscription;
constructor(public formService: FormService) {
this.enableAutoSave();
}
enableAutoSave() {
this.autoSaveSubscription = this.formService.formFieldValueChanged
.pipe(debounceTime(350))
.subscribe((e: FormEvent) => {
this.formService.saveTaskForm(this.taskId, e.form.values);
});
}
abstract ngOnDestroy(); // make sure any component that extends this abstract component gets unsubscribed from autoSave subscription
}