-
Notifications
You must be signed in to change notification settings - Fork 588
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
perf improvement: remove handler from onlookersetsubscribers as tooltip changes #5019
perf improvement: remove handler from onlookersetsubscribers as tooltip changes #5019
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
app/packages/core/src/components/Modal/ModalSamplePlugin.tsx (1)
3-3
: Remove unused importuseCallback
.The
useCallback
hook is imported but not utilized in the component. Consider removing it to maintain clean imports.-import React, { Suspense, useCallback, useEffect, useMemo } from "react"; +import React, { Suspense, useEffect, useMemo } from "react";
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/packages/core/src/components/Modal/ModalSamplePlugin.tsx
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/core/src/components/Modal/ModalSamplePlugin.tsx (1)
Pattern **/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
🔇 Additional comments (2)
app/packages/core/src/components/Modal/ModalSamplePlugin.tsx (2)
57-74
: Well-implemented cleanup logic!
The useEffect implementation properly manages both the subscription and cleanup of tooltip event listeners. The dependency array is complete, and the cleanup function ensures that both the event listener and subscriber are removed correctly.
57-74
: Verify memory cleanup with multiple modal operations.
While the implementation looks correct, it's important to verify that memory is properly cleaned up after multiple modal open/close operations.
✅ Verification successful
Memory cleanup implementation is correctly handled
The implementation properly manages cleanup through multiple mechanisms:
- The
onLookerSetSubscribers
array is maintained in the Modal component and shared via context - Event listeners are properly added and removed in the cleanup function
- The subscriber list is correctly filtered during cleanup to remove the specific listener
- The cleanup pattern is consistent across the codebase with no conflicting implementations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other uses of onLookerSetSubscribers to ensure consistent cleanup
rg -A 5 "onLookerSetSubscribers" --type ts --type tsx
Length of output: 81
Script:
#!/bin/bash
# Search for onLookerSetSubscribers with correct file type patterns
rg -A 5 "onLookerSetSubscribers" -g "*.tsx" -g "*.ts"
# Search for any tooltip-related event listeners to verify cleanup patterns
rg -A 5 "tooltip.*EventListener" -g "*.tsx" -g "*.ts"
# Search for Modal component usage patterns
rg -A 5 "ModalSamplePlugin" -g "*.tsx" -g "*.ts"
Length of output: 7621
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Much smoother now! 🧈
What changes are proposed in this pull request?
Before this, we were not cleaning up on-looker-set subscribers.
How is this patch tested? If it is not, please explain why.
Locally.
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit