I know that tap is use for side effects of an Observable, i see that it's similar to subscribe. here is an example:
import { from } from 'rxjs';
import { tap } from 'rxjs/operators';
observable$ = from([1,2,3,4]);
// we can add error callback in tap
observable$.pip(
tap({
next(value) { console.log(value) },
error(error) { console.log(error) }
})
).subscribe(console.log);
// and we can do it inside subscribe
observable$.pip(
tap()
).subscribe(
(value) => {console.log(value)},
(error) => { console.log(error)
);
what is the difference in details and in which cases, tap will be useful