Skip to content

Instantly share code, notes, and snippets.

@umar-muneer
umar-muneer / faulty-component.ts
Created Aug 12, 2021
Keep the Observable alive after error
View faulty-component.ts
public class Component {
constructor(private service: Service) {}
handleClick$ = new Subject();
ngOnInit() {
this.handleClick$.pipe(
switchMap(() => {
return this.service.someObservable$;
})
).subscribe(console.log);
// this observable would stop firing as soon as there is an error, subsequent button clicks will not trigger it.