-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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: event mixin types #10543
fix: event mixin types #10543
Conversation
My review is in progress 📖 - I will have feedback for you in a few minutes! |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ed92806:
|
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 have reviewed your code and found 6 potential issues. To discuss my individual comments that I have added, tag me in replies using @korbit-ai.
Please react with a 👍 to my comments that you find helpful and a 👎 to those you find unhelpful - this will help me learn and improve as we collaborate.
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 like this change. Flattening the layers of abstractions for events is welcome.
Ok so this PR was a fun rabbit hole 😄
Overview
The main overview of what this PR is actually changing is that i have removed the abstraction of
IFederatedEventTarget
in favour of just usingContainer
.IFederatedContainer
is still mixed into theContainer
, which means that all types should work as before.I believe this change reflects a more accurate description of what object is stored in an
FederatedEvent
.The benefits of this is that we don't need to do any typescript magic that decouples the two different implementations of
EventEmitter
e.gThis
Becomes this
What Is This Fixing
The current implementation revealed a nasty bug with using our
PixiMixins
that is hidden in v7 due toContainer
extendingDisplayObject
and everyone will be attaching there custom properties toContainer
, notDisplayObject
, because of this we have never seen the issue.Hopefully i can try and explain it here...
If you try to add your own properties to
Container
in v8 currently like this:Then you try to override and use these methods like:
We get two TS errors:
Class 'Container
defines instance member propertyoverrideMethod
, but extended classNewContainer
defines it as instance member function.Container
The first issue is that typescript believe the
overrideMethod
is a property onContainer
and not a method. So it wants you to declare it like thisHowever this isn't accurate as if we wanted to declare it as a property it should be defined like this
The second issue is that
this
is not being respected correctly. It should be returningNewContainer
, however it always returnsContainer
Now I have zero idea what sort of typescript magic is going on that messes up these types so badly but the change here is minimal and seems to work.