I'm trying to implement form data autosave in Angular 4. It should work like this:
I suppose that Observable, Subject and Scheduler from RxJS will help me, but I am completely new to it. Could you suggest the best approach for achieving above functionality please?
You can just subscribe to valueChanges property on FormGroup object chained with the auditTime operator:
this.form.valueChanges.auditTime(2000).subscribe(formData => /* save to DB */)
Maybe also have a look at throttleTime and debounceTime operators.
For Angular 6, you may have to use pipe.
this.form.valueChanges.pipe(auditTime(2000)).subscribe(formData => /* save to DB */)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With