-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chore: upgrade eventemitter to v5.0.2 #7709
Conversation
@@ -237,13 +237,11 @@ export default { | |||
} | |||
|
|||
this.previewAction = new PreviewAction(this.openmct); | |||
this.previewAction.on('isVisible', this.togglePreviewState); |
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.
this.togglePreviewState
was undefined, and this wasn't doing anything except making our unit tests fail. It seems that the new version throws an exception if you try to unregister a listener that doesn't exist, or register a listener without context.
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 think you're right. I wonder if our preview action changed at some point as it doesn't seem to have much benefit to emitting this 'isVisible' event at all.
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.
It seems that the new version throws an exception if you try to unregister a listener that doesn't exist, or register a listener without context.
From v3.0.0 onwards, EventEmitter3 throws an error if you try to register a listener with a callback that is not a function
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.
Actually, this is being used for search results here:
https://github.com/nasa/openmct/blob/master/src/ui/layout/search/SearchResultsDropDown.vue#L48
It was likely a copy-paste error where the this.togglePreviewState
method was not added. It is also missing in AnnotationSearchResult.vue
You can see an implementation here:
https://github.com/nasa/openmct/blob/master/src/ui/layout/RecentObjectsListItem.vue#L116
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7709 +/- ##
==========================================
- Coverage 56.87% 56.57% -0.31%
==========================================
Files 673 673
Lines 27182 27178 -4
Branches 2635 2635
==========================================
- Hits 15461 15376 -85
- Misses 11390 11471 +81
Partials 331 331
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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 just had a couple minor suggestions but really good.
@@ -79,7 +79,6 @@ import Browse from './ui/router/Browse.js'; | |||
export class MCT extends EventEmitter { | |||
constructor() { | |||
super(); | |||
EventEmitter.call(this); |
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.
Whaaaat were we even doing here? Suspect this was a hangover from prototypical inheritance that was left in by mistake.
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.
Yup, exactly.
@@ -41,7 +41,7 @@ const helperFunctions = { | |||
} else if (object.addEventListener) { | |||
object.addEventListener(event, listener._cb); | |||
} else { | |||
object.on(event, listener._cb); |
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.
Wait, so how was this working before? The context would have been undefined?
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.
Changes look good to me. My only question is all the cases where we are now providing a context object for the callback function. Why is that suddenly necessary, and how was it working previously with an undefined
context?
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.
Need to confirm with Jamie and David
@@ -171,7 +170,6 @@ export default { | |||
this.updateCurrentTab = this.updateCurrentTab.bind(this); | |||
this.openmct.router.on('change:params', this.updateCurrentTab); | |||
|
|||
this.RemoveAction = new RemoveAction(this.openmct); |
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.
Hmm
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.
It was never used
@@ -50,11 +50,12 @@ | |||
<script> | |||
import { inject } from 'vue'; | |||
|
|||
import { PREVIEW_ACTION_KEY } from '@/ui/preview/PreviewAction.js'; |
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 don't think we can have aliased imports due to the JPL codebase @davetsay @jvigliotta
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.
This is only true for files that they import directly from source (🙈). @jvigliotta @davetsay which files are we honor-bound to keep webpack-alias-free?
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.
Good looking out, @unlikelyzero . We'll fix this on the OMM side. Core should not worry about using or not using aliased imports. As long as we use the same webpack aliases in OMM it will work (🙈+1).
Co-authored-by: David Tsay <[email protected]>
e12ea9c
to
c323b5b
Compare
In v1.2.0 (and beyond), if no context is provided, it will fall back to using the EventEmitter context, which seemed to work for our purposes before. As a part of these changes, I converted Draw2D and DrawWebGL to ES6 classes, so the default context there becomes the class instance instead of the caller. So we need to explicitly pass the context to the EE to preserve the previous behavior. |
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.
Great work, @ozyx. Definitely more worthy work than chore
gives it credit for.
@@ -107,23 +111,33 @@ export default { | |||
}; | |||
}, | |||
watch: { | |||
async currentView() { | |||
// wait for view to render with next tick | |||
await nextTick(); |
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.
Gross, thank you.
Deferring to post RC5 |
let's merge? |
Closes #4656
Closes #6426
Describe your changes:
Upgrades
eventemitter3
library to the latest version5.0.2
.eventHelpers
All Submissions:
Author Checklist
type:
label? Note: this is not necessarily the same as the original issue.Reviewer Checklist