Typically, a tap
pipe is used for side effects like logging. In this scenario, the goal is simply to set the isLoading
property to false
. However, it's important that this action occurs regardless of whether the notification type is next or error. This requires duplicating the code:
something.pipe(
tap({
next: () => {
this.isLoading = false;
},
error: () => {
this.isLoading = false;
}
}),
)
Is there a way to configure tap
so that only one callback function needs to be provided, which will run regardless of the notification type? For example:
something.pipe(
anyTap(() => {
this.isLoading = false;
}),
)
In this setup, no matter what something
returns, the anyTap
function will always execute its callback function.