Subscribe is deprecated: Use an observer instead of an error callback

RxJS deprecated some signatures of the subscribe method, which might have caused some confusion. The subscribe method itself isn’t deprecated, only the variant we’re using is deprecated. So here it looks like

.subscribe({ 
next: (response) => { console.log(response); },
error: (e) => { console.log(e); } 
});


or 


.subscribe({
next(response) { console.log(response) },
error(e) { console.log(e); }
});

See these GitHub issues:

import { of } from 'rxjs';

// deprecated
of([1,2,3]).subscribe(null, null, console.info); // difficult to read
// suggested change
of([1,2,3]).subscribe({complete: console.info});
import { throwError } from 'rxjs';

// deprecated 
throwError('I am an error').subscribe(null, console.error);
// suggested change
throwError('I am an error').subscribe({error: console.error});
import { of } from 'rxjs';

// recommended 
of([1,2,3]).subscribe((v) => console.info(v));
// also recommended
of([1,2,3]).subscribe({
    next: (v) => console.log(v),
    error: (e) => console.error(e),
    complete: () => console.info('complete') 
})

/Siva