Skip to content

Commit

Permalink
refactor: use a const for the EventBus event name and store it in the…
Browse files Browse the repository at this point in the history
… eventBus.ts

Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Dec 29, 2024
1 parent e8d9c3c commit df078a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import {
mdiThermometer,
} from '@mdi/js'
import { additionalSensors, opacityHeaterActive, opacityHeaterInactive } from '@/store/variables'
import { EventBus } from '@/plugins/eventBus'
import { CLOSE_TEMPERATURE_CONTEXT_MENU, EventBus } from '@/plugins/eventBus'
@Component
export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
Expand Down Expand Up @@ -305,15 +305,15 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
}
mounted() {
EventBus.$on('close-temperature-context-menu', this.closeContextMenu)
EventBus.$on(CLOSE_TEMPERATURE_CONTEXT_MENU, this.closeContextMenu)
}
beforeDestroy() {
EventBus.$off('close-temperature-context-menu', this.closeContextMenu)
EventBus.$off(CLOSE_TEMPERATURE_CONTEXT_MENU, this.closeContextMenu)
}
openContextMenu(event: MouseEvent) {
EventBus.$emit('close-temperature-context-menu')
EventBus.$emit(CLOSE_TEMPERATURE_CONTEXT_MENU)
this.showContextMenu = true
this.contextMenuX = event?.clientX || event?.pageX || window.screenX / 2
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/eventBus.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import Vue from 'vue'
export const EventBus = new Vue()

export const CLOSE_TEMPERATURE_CONTEXT_MENU = 'close-temperature-context-menu'

0 comments on commit df078a5

Please sign in to comment.