I have the encountered a code in a project that I started to maintain. There is a switch block where is some lines return EMPTY
in each case as shown below:
update(data) {
this.demoService
.update(data)
.pipe(
// ...
catchError((err:any) => {
switch (err.status) {
case 400:
// display message
return EMPTY;
case 403
// display message
return EMPTY;
case 500
// display message
return EMPTY;
default:
return EMPTY;
}
// return EMPTY; //can I use only this EMPTY instead of above ones?
}),
)
.subscribe();
}
I am wondering does it make any sense using it as shown above or at the end of switch block? I am new in RxJs and not sure if return EMPTY
in each case has special meaning (there is also no break
maybe due to return
).
1 thought on “Using RxJs EMPTY in switch statement”