-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(core): clean up event-handling in Observable #10531
Conversation
I've not yet added tests, but happy to do so later (bedtime for now) – just opening it up for code review for the time being. |
c8586ae
to
1e0ec99
Compare
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.
After a quick look, I left a comment about trim()
calls. We might have to be careful about this in all event name iterations.
Looks like a couple of unit tests are failing. Will check later what’s up. |
I've pushed a commit that I believe will fix the failing CI tests (I'd forgotten to pass along the I've spoken with @farfromrefug on Discord and it sounds like neither the I might as well add some unit tests characterise the things I've mentioned in the description as being fixed by these changes (which I'll need a free moment to undertake). Welcoming any more input in the meantime. |
Okay, I fixed a unit test, but there's still an iOS E2E test failing (and I haven't looked at Android yet). I figured out why the iOS test is failing. With the old behaviour, when you'd call By contrast, in The test concerns |
Unit testsI've added some unit tests now that set in stone some of the aspects of event listener identity that were unclear/inconsistent before. Removing the ability to split event names@edusperoni I agree that we should remove the functionality for splitting event names. From my chat with @farfromrefug on Discord, we're not aware of any usage of multiple event names outside of gesture-handling in Core, so I'm optimistic that removing it would pose no risk to community plugins. This may give us a small speed boost, as we're pointlessly splitting all event names at the moment, regardless of whether they need it. However, I'd prefer to implement that in a follow-up PR, to keep the scope of this one small. Trimming/splitting approachThis PR currently uses Next stepsAwaiting review! |
@CatchABus @farfromrefug @edusperoni Sorry to poke. Is anything holding this back from approval? There's much more left to clean up across Core and I'd like to move onto the next PR! |
Not on my side. |
1010706
to
9670589
Compare
Relates to #10534. These two PRs are independent and can be merged in either order.
This PR cleans up the event-handling in Observable. It's mostly a code-level thing, but see the details below for some minor differences in behaviour (which arguably unbreak things that had been broken to begin with).
It doesn't implement DOM Events or anything, so should be fairly uncontroversial.
The git diff is rather hard to read, so I'd recommend just reading the latest code directly.
PR Checklist
What is the current behavior?
callback
, samethisArg
), which is strange when compared to DOM Events.addEventListener
, yet not the static one.once
is mostly a copy-paste ofaddEventListener
).removeEventListener
do the same thing, yet differ).What is the new behavior?
All of the above points are addressed.
Potentially breaking changes:
once?: boolean
parameter to the signature ofaddEventListener
. In theory this shouldn't be a breaking change, but in case renderers are relying on passing an arg into that (e.g. as a workaround for supportingAddEventListenerOptions
), I've added aaddEventListenerSchemaVersion
property to Observable so that they can check at runtime whether the given version of Core follows the expected call signature.addEventListener
, rather than reusing an existing one.