Issue
Is there a way to attach a handler when an observable starts executing (someone called subscribe on it)?
like in angular:
this.http.post('someUrl', resource).pipe(
catchError(),
finalize((() => this.hideLoader()),
**executing(() => this.showLoader()) <------**
)
Solution
The defer
observable factory function is most likely what you are looking for:
import { defer } from 'rxjs';
const post = defer(() => {
this.showLoader();
return this.http.post('someUrl', resource).pipe(
catchError(),
finalize(() => this.hideLoader())
);
});
post.subscribe();
Answered By - cartant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.