Skip to content

Commit 1bac48d

Browse files
committed
fix(interceptor): Fixed issue with not unsubscribing
1 parent 5db4bc9 commit 1bac48d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/interceptor-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export class InterceptorService extends Http {
8484
() => observer.complete()
8585
);
8686
observer.add(() => {
87+
subscription.unsubscribe();
8788
this.interceptors.reverse().forEach((interceptor, index) => {
8889
if (interceptor.onUnsubscribe !== undefined) {
8990
interceptor.onUnsubscribe(index, url, options);

src/interceptor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export interface Interceptor {
7979
/**
8080
* Invoked when the user unsubscribes while the request is still being handled
8181
* Use this method to perform cleanup operations that should be performed when the request is cancelled by user
82-
* such as stopping progress bar
82+
* such as stopping progress bar.
83+
* NOTE: This method would be invoked even if none of the other handler methods are called on the interceptor.
84+
* So, always do null checks in this handler
8385
*/
8486
onUnsubscribe?(interceptorStep: number, url: string | Request, options?: RequestOptionsArgs | InterceptorRequestOptionsArgs): void;
8587

0 commit comments

Comments
 (0)