Skip to content

Instantly share code, notes, and snippets.

@jedrekk
Created September 3, 2019 16:05
Show Gist options
  • Save jedrekk/778226076a22ef0f762c0a51b02292c7 to your computer and use it in GitHub Desktop.
Save jedrekk/778226076a22ef0f762c0a51b02292c7 to your computer and use it in GitHub Desktop.
import Vue from 'vue'
export default new Vue()
<script>
import EventBus from '@/services/event-bus'
export default {
name: 'NewPopover',
computed: {},
watch: {
showPopper (newVal, oldVal) {
if (newVal) {
this.disableBusListener()
EventBus.$emit('close-all-popovers')
setTimeout(this.enableBusListener, 10)
} else {
this.disableBusListener()
}
}
},
beforeDestroy () {
this.disableBusListener()
},
methods: {
disableBusListener () {
EventBus.$off('close-all-popovers')
},
enableBusListener () {
EventBus.$on('close-all-popovers', () => {
console.log('got close-all-popovers event')
this.showPopper = false
})
},
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment