-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Move command type out of listeners to registerCommandListener
#1551
Conversation
This pull request is being automatically deployed with Vercel (learn more). lexical – ./packages/lexical-website🔍 Inspect: https://vercel.com/fbopensource/lexical/2SkLtyig8xrcnasmZ4znRrjA82uL lexical-playground – ./packages/lexical-playground🔍 Inspect: https://vercel.com/fbopensource/lexical-playground/3mGotWvrgU7Q7p367sWbANdkyavM lexical-website-new – ./packages/lexical-website-new🔍 Inspect: https://vercel.com/fbopensource/lexical-website-new/EGHR2sU2KtpGCG9hrQzQX6zn1CJi |
fe53120
to
5b32429
Compare
1c3d926
to
9e58c29
Compare
95f0b0c
to
bfa9a0b
Compare
35ae42c
to
4aec50a
Compare
* Move command type out of listener callback to registerCommandListener outer method * Remove optional chaining * correct boolean values returned from some command callbacks * Fix bug with priorty ordering * clarify type * Fix failing E2E * Fix E2E bug * Wrap mutiple commands in withSubscriptions * update docs * Address small issues and add unit test * remove console logs * Fix E2E bugs * Fix E2E bugs * Remove flow fixmes and add invariant
Following on from #1412 and #1512, we're trying to store commands by their type, and then by their priority order. This should allow us call listeners less often, and removes the need for users to have to check types in callbacks. Plus it should allow us to more easily type the commands themselves.
This effectively changes how we store the command from the below:
In terms of performance, I don't think we're taking much of a hit, especially since #1509.
I 6x throttled the CPU of Chrome, and compared the task times for typing characters compared to
main
, and they average around the same number of milliseconds.I was also able to add
console.startEnd
andconsole.startEnd
to the beginning and end ofexecCommand
and the times for the function to run appear fairly consistent across this and main.main
branch