Q:

Cancel subscribe of request Angular

I'm sending any requests on angular to back-end part. I send the same request with different parameters when entering new values ​​into the input, due to the server’s response, the data is updated to the front end part. How I can implement cancellation of waiting for an old request if a new one has already been sent? In order not to render components for each request, but only for the last?
Some code of this:
    getNotes() {
    this.isLoaded = false;
    this.noteService.getNotes(this.page, this.sortBy, this.searchNoteValue)
        .subscribe((notes: Note[]) => {
            this.userNotes = notes;
            this.isLoaded = true;
        }});
    }

A:

A simple way would be define a property notesSubscription: Subscription
import { Subscription } from 'rxjs';
...
notesSubscription: Subscription;

and modify your getNotes method
getNotes() {
this.isLoaded = false;
if (this.notesSubscription) {
    this.notesSubscription.unsubscribe();
}
this.notesSubscription = this.noteService.getNotes(this.page, this.sortBy, this.searchNoteValue)
    .subscribe((notes: Note[]) => {
        this.userNotes = notes;
        this.isLoaded = true;
    }});
}

Regards

