mirror of
https://github.com/nasa/openmct.git
synced 2025-03-13 07:54:13 +00:00
remove eventemitter and use native custom events
This commit is contained in:
parent
55d15caa63
commit
8545ddeaff
@ -136,9 +136,8 @@ export default {
|
|||||||
this.resize = _.debounce(this.resize, 400);
|
this.resize = _.debounce(this.resize, 400);
|
||||||
this.eventStripResizeObserver = new ResizeObserver(this.resize);
|
this.eventStripResizeObserver = new ResizeObserver(this.resize);
|
||||||
this.eventStripResizeObserver.observe(this.$refs.events);
|
this.eventStripResizeObserver.observe(this.$refs.events);
|
||||||
|
this.extendedLinesBus.addEventListener('disable-extended-lines', this.disableExtendEventLines);
|
||||||
this.extendedLinesBus.on('disable-extended-lines', this.disableExtendEventLines);
|
this.extendedLinesBus.addEventListener('enable-extended-lines', this.enableExtendEventLines);
|
||||||
this.extendedLinesBus.on('enable-extended-lines', this.enableExtendEventLines);
|
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
if (this.eventStripResizeObserver) {
|
if (this.eventStripResizeObserver) {
|
||||||
@ -153,9 +152,11 @@ export default {
|
|||||||
this.destroyEventContainer();
|
this.destroyEventContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.extendedLinesBus.off('disable-extended-lines', this.disableExtendEventLines);
|
this.extendedLinesBus.removeEventListener(
|
||||||
this.extendedLinesBus.off('enable-extended-lines', this.enableExtendEventLines);
|
'disable-extended-lines',
|
||||||
this.extendedLinesBus.off('event-hovered', this.checkIfOurEvent);
|
this.disableExtendEventLines
|
||||||
|
);
|
||||||
|
this.extendedLinesBus.removeEventListener('enable-extended-lines', this.enableExtendEventLines);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setTimeContext() {
|
setTimeContext() {
|
||||||
@ -164,16 +165,17 @@ export default {
|
|||||||
this.timeContext.on('timeSystem', this.setScaleAndPlotEvents);
|
this.timeContext.on('timeSystem', this.setScaleAndPlotEvents);
|
||||||
this.timeContext.on('boundsChanged', this.updateViewBounds);
|
this.timeContext.on('boundsChanged', this.updateViewBounds);
|
||||||
},
|
},
|
||||||
enableExtendEventLines(keyStringToEnable) {
|
enableExtendEventLines(event) {
|
||||||
|
const keyStringToEnable = event.detail;
|
||||||
if (this.keyString === keyStringToEnable) {
|
if (this.keyString === keyStringToEnable) {
|
||||||
this.extendLines = true;
|
this.extendLines = true;
|
||||||
this.emitExtendedLines();
|
this.emitExtendedLines();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
disableExtendEventLines(keyStringToDisable) {
|
disableExtendEventLines(event) {
|
||||||
|
const keyStringToDisable = event.detail;
|
||||||
if (this.keyString === keyStringToDisable) {
|
if (this.keyString === keyStringToDisable) {
|
||||||
this.extendLines = false;
|
this.extendLines = false;
|
||||||
// emit an empty array to clear the lines
|
|
||||||
this.emitExtendedLines();
|
this.emitExtendedLines();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -20,18 +20,36 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import { EventEmitter } from 'eventemitter3';
|
export default class ExtendedLinesBus extends EventTarget {
|
||||||
export default class ExtendedLinesBus extends EventEmitter {
|
|
||||||
updateExtendedLines(keyString, lines) {
|
updateExtendedLines(keyString, lines) {
|
||||||
this.emit('update-extended-lines', { lines, keyString });
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('update-extended-lines', {
|
||||||
|
detail: { keyString, lines }
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
disableExtendEventLines(keyString) {
|
disableExtendEventLines(keyString) {
|
||||||
this.emit('disable-extended-lines', keyString);
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('disable-extended-lines', {
|
||||||
|
detail: keyString
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
enableExtendEventLines(keyString) {
|
enableExtendEventLines(keyString) {
|
||||||
this.emit('enable-extended-lines', keyString);
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('enable-extended-lines', {
|
||||||
|
detail: keyString
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHoverExtendEventLine(keyString, id) {
|
updateHoverExtendEventLine(keyString, id) {
|
||||||
this.emit('update-extended-hover', { id, keyString });
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('update-extended-hover', {
|
||||||
|
detail: { keyString, id }
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,16 +127,16 @@ export default {
|
|||||||
this.stopFollowingTimeContext();
|
this.stopFollowingTimeContext();
|
||||||
this.handleContentResize.cancel();
|
this.handleContentResize.cancel();
|
||||||
this.contentResizeObserver.disconnect();
|
this.contentResizeObserver.disconnect();
|
||||||
this.extendedLinesBus.off('update-extended-lines', this.updateExtendedLines);
|
|
||||||
this.extendedLinesBus.off('update-extended-hover', this.updateExtendedHover);
|
|
||||||
this.openmct.selection.off('change', this.checkForLineSelection);
|
this.openmct.selection.off('change', this.checkForLineSelection);
|
||||||
|
this.extendedLinesBus.removeEventListener('update-extended-lines', this.updateExtendedLines);
|
||||||
|
this.extendedLinesBus.removeEventListener('update-extended-hover', this.updateExtendedHover);
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.setTimeContext();
|
this.setTimeContext();
|
||||||
|
|
||||||
this.extendedLinesBus.on('update-extended-lines', this.updateExtendedLines);
|
this.extendedLinesBus.addEventListener('update-extended-lines', this.updateExtendedLines);
|
||||||
this.extendedLinesBus.on('update-extended-hover', this.updateExtendedHover);
|
this.extendedLinesBus.addEventListener('update-extended-hover', this.updateExtendedHover);
|
||||||
this.openmct.selection.on('change', this.checkForLineSelection);
|
this.openmct.selection.on('change', this.checkForLineSelection);
|
||||||
|
|
||||||
if (this.composition) {
|
if (this.composition) {
|
||||||
@ -271,10 +271,12 @@ export default {
|
|||||||
this.timeContext.off('clockChanged', this.updateViewBounds);
|
this.timeContext.off('clockChanged', this.updateViewBounds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateExtendedLines({ keyString, lines }) {
|
updateExtendedLines(event) {
|
||||||
|
const { keyString, lines } = event.detail;
|
||||||
this.extendedLinesPerKey[keyString] = lines;
|
this.extendedLinesPerKey[keyString] = lines;
|
||||||
},
|
},
|
||||||
updateExtendedHover({ keyString, id }) {
|
updateExtendedHover(event) {
|
||||||
|
const { keyString, id } = event.detail;
|
||||||
this.extendedLineHover = { keyString, id };
|
this.extendedLineHover = { keyString, id };
|
||||||
},
|
},
|
||||||
checkForLineSelection(selection) {
|
checkForLineSelection(selection) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user