Here is my tap
operator with next
, error
and complete
, though there is no error
always it's called. so my users
always empty. how to use the tap
operator with correct way?
readonly fetchUsers$ = this.effect(($) =>
$.pipe(
tap(() => this.setState({ users: [], status: 'authenticating' })),
switchMap(() =>
this.dataService.getUsers().pipe(
tap({
next: (data: UserProps[]) => {
this.setUsers(data);
},
error: () => this.setState({ users: [], status: 'error' }),//always called
finalize: (data:UserProps[]) => this.setState({ users: data, status: 'complete' }),
}),
catchError(() => EMPTY)
)
)
)
);