Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debounce new requests changes coming from the callback #90

Merged
merged 3 commits into from
Dec 22, 2023

Conversation

jwallet
Copy link
Contributor

@jwallet jwallet commented Dec 19, 2023

If you click rapidly on make requests in the example, you will find out that the app freezes (even if the logger is paused). The amount of re-render is just crazy for the setCallback subscriber in NetworkLogger.

  • I added a refreshRate to debounce the callback, so the subscriber do not get 50 events in the same milisecond, default to 50milliseconds. This option was added to StartNetworkLoggingOptions
  • I added a updatedAt property on the Request class, so you can publish through the callback only when requests are being updated or added, clearing the requests array will reset the latestRequestUpdatedAt to 0
  • I spreaded the array before sending it through the callback to prevent mutation of requests for all subscribers
before (i clicked like 30 times on pause -- not responding)
Screen.Recording.2023-12-18.at.7.25.18.PM.mov
after
Screen.Recording.2023-12-18.at.7.21.39.PM.mov

@alexbrazier
Copy link
Owner

I tried to resolve the conflicts here but looks like I don't have permission to push

@jwallet
Copy link
Contributor Author

jwallet commented Dec 21, 2023

Yes the company settings don't allow that, I will have to merge conflicts myself

Copy link
Owner

@alexbrazier alexbrazier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks like quite a big improvement

@alexbrazier alexbrazier merged commit 009303d into alexbrazier:master Dec 22, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants