-
Notifications
You must be signed in to change notification settings - Fork 374
Refactor: More state management simplification #5721
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
Conversation
The function expression → declaration change is half stylistic and half precautionary. The bug shows up when the event listener holds on to a reference that's further down in scope and gets wiped. |
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.
Very nice
rafId = null | ||
}) | ||
} | ||
const { resume: handleTransformUpdate } = useRafFn(updateVisibility, { |
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.
Shall we expose the pause()
function? We can pause when the TransformPane emits the "stopped transforming" event (or something similar).
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.
I actually want to get rid of this entirely and just have the nodes react to changes in the transformPane (throttled)
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.
Isn't that what was happening already?
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.
Nope, it's querying the document with every call.
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.
Looking at it, I initially thought handleTransformUpdate
was only called when a transform event is emitted by TransformPane
which would then trigger an updateVisibility
.
I thought resume
from useRafFn
essentially started calling the rafFn every frame until pause
is called. So now, we are resume
when transform is emitted -> starting a call every frame. But before, we just called on every frame that a transform is emitted. Is that wrong?
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.
Well, the TransformPane
is emitting update event every frame anyway, because it's using useCanvasTransformSync
which just simply uses its own rafFn that runs every frame, so I'm incorrect afterall.
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.
I tested by adding console.count
call in handleTransformUpdate
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.
You were right locally, but that does explain why this code didn't tank performance relative to baseline like it would have otherwise 😁
a4fd9b6
to
84f8aa8
Compare
🎭 Playwright Test Results✅ All tests passed! ⏰ Completed at: 09/22/2025, 07:42:46 PM UTC 📈 Summary
📊 Test Reports by Browser
🎉 Click on the links above to view detailed test results for each browser configuration. |
d6eb6d8
to
32af5a7
Compare
32af5a7
to
b992c12
Compare
Summary
Remove more procedural synchronization in favor of using reactive references.
Review Focus
In testing it seems to work the same, but let me know if I missed something.
┆Issue is synchronized with this Notion page by Unito