@hyper-fetch/core 5.4.1 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -713,22 +713,42 @@ declare class Client<GlobalErrorType extends ClientErrorType = Error, Adapter ex
713
713
  * Method of manipulating requests before sending the request. We can for example add custom header with token to the request which request had the auth set to true.
714
714
  */
715
715
  onAuth: (callback: RequestInterceptorType) => Client<GlobalErrorType, Adapter, EndpointMapper>;
716
+ /**
717
+ * Method for removing listeners on auth.
718
+ * */
719
+ removeOnAuthInterceptors: (callbacks: RequestInterceptorType[]) => Client<GlobalErrorType, Adapter, EndpointMapper>;
716
720
  /**
717
721
  * Method for intercepting error responses. It can be used for example to refresh tokens.
718
722
  */
719
723
  onError: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType, Adapter>) => Client<GlobalErrorType, Adapter, EndpointMapper>;
724
+ /**
725
+ * Method for removing listeners on error.
726
+ * */
727
+ removeOnErrorInterceptors: (callbacks: ResponseInterceptorType<any, null | GlobalErrorType, Adapter>[]) => Client<GlobalErrorType, Adapter, EndpointMapper>;
720
728
  /**
721
729
  * Method for intercepting success responses.
722
730
  */
723
731
  onSuccess: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType, Adapter>) => Client<GlobalErrorType, Adapter, EndpointMapper>;
732
+ /**
733
+ * Method for removing listeners on success.
734
+ * */
735
+ removeOnSuccessInterceptors: (callbacks: ResponseInterceptorType<any, null | GlobalErrorType, Adapter>[]) => Client<GlobalErrorType, Adapter, EndpointMapper>;
724
736
  /**
725
737
  * Method of manipulating requests before sending the request.
726
738
  */
727
739
  onRequest: (callback: RequestInterceptorType) => Client<GlobalErrorType, Adapter, EndpointMapper>;
740
+ /**
741
+ * Method for removing listeners on request.
742
+ * */
743
+ removeOnRequestInterceptors: (callbacks: RequestInterceptorType[]) => Client<GlobalErrorType, Adapter, EndpointMapper>;
728
744
  /**
729
745
  * Method for intercepting any responses.
730
746
  */
731
747
  onResponse: <ErrorType = null>(callback: ResponseInterceptorType<any, GlobalErrorType | ErrorType, Adapter>) => Client<GlobalErrorType, Adapter, EndpointMapper>;
748
+ /**
749
+ * Method for removing listeners on request.
750
+ * */
751
+ removeOnResponseInterceptors: (callbacks: ResponseInterceptorType<any, null | GlobalErrorType, Adapter>[]) => Client<GlobalErrorType, Adapter, EndpointMapper>;
732
752
  /**
733
753
  * Add persistent effects which trigger on the request lifecycle
734
754
  */
package/dist/index.esm.js CHANGED
@@ -2276,22 +2276,42 @@ var Client = class {
2276
2276
  this.__onAuthCallbacks.push(callback);
2277
2277
  return this;
2278
2278
  };
2279
+ this.removeOnAuthInterceptors = (callbacks) => {
2280
+ this.__onAuthCallbacks = this.__onAuthCallbacks.filter((callback) => !callbacks.includes(callback));
2281
+ return this;
2282
+ };
2279
2283
  this.onError = (callback) => {
2280
2284
  this.__onErrorCallbacks.push(callback);
2281
2285
  return this;
2282
2286
  };
2287
+ this.removeOnErrorInterceptors = (callbacks) => {
2288
+ this.__onErrorCallbacks = this.__onErrorCallbacks.filter((callback) => !callbacks.includes(callback));
2289
+ return this;
2290
+ };
2283
2291
  this.onSuccess = (callback) => {
2284
2292
  this.__onSuccessCallbacks.push(callback);
2285
2293
  return this;
2286
2294
  };
2295
+ this.removeOnSuccessInterceptors = (callbacks) => {
2296
+ this.__onSuccessCallbacks = this.__onSuccessCallbacks.filter((callback) => !callbacks.includes(callback));
2297
+ return this;
2298
+ };
2287
2299
  this.onRequest = (callback) => {
2288
2300
  this.__onRequestCallbacks.push(callback);
2289
2301
  return this;
2290
2302
  };
2303
+ this.removeOnRequestInterceptors = (callbacks) => {
2304
+ this.__onRequestCallbacks = this.__onRequestCallbacks.filter((callback) => !callbacks.includes(callback));
2305
+ return this;
2306
+ };
2291
2307
  this.onResponse = (callback) => {
2292
2308
  this.__onResponseCallbacks.push(callback);
2293
2309
  return this;
2294
2310
  };
2311
+ this.removeOnResponseInterceptors = (callbacks) => {
2312
+ this.__onResponseCallbacks = this.__onResponseCallbacks.filter((callback) => !callbacks.includes(callback));
2313
+ return this;
2314
+ };
2295
2315
  this.addEffect = (effect) => {
2296
2316
  this.effects = this.effects.concat(effect);
2297
2317
  return this;