Closed stefanullinger closed 1 year ago
Hi @stefanullinger, we will add the methods for removing listeners this week - that's a good idea. If you need to remove it now, I guess the current approach would be:
const requestCallback = ...
const resposneCallback = ...
client.onRequest(requestCallback)
client.onResponse(responseCallback)
client.__onRequestCallbacks = client.__onRequestCallbacks.filter((callback) => callback !== requestCallback);
client.__onResponseCallbacks = ...
Also, we have it on our roadmap to add the hook that allows you to look up all the requests!
:tada: This issue has been resolved in version 5.5.0 :tada:
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
Is your feature request related to a problem? Please describe. In my React app I would like to add some visual activity log for API requests / responses similar to the network tab of the browser's developer tools. The app user should be globally notified about API errors and should not need to open the developer tools.
I saw that I can use
client.onRequest
andclient.onResponse
methods to add some listeners.Now I wanted to put this into a custom React hook. I have added the listeners inside of some useEffect hook, but it seems that I am not able to do some cleanup, because there is no way to remove the listeners yet, right?
Is there some way to remove the listeners, or would you recommend another approach?