mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
Update the nuxt3 version. Co-authored-by: Jonathan Adeline <jonathan@baserow.io> Co-authored-by: Bram Wiepjes <bramw@protonmail.com> Co-authored-by: Cezary <cezary@baserow.io> Co-authored-by: Tsering Paljor <tsering@baserow.io> Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io> Co-authored-by: Bram <bram2w@users.noreply.github.com>
32 lines
601 B
JavaScript
32 lines
601 B
JavaScript
import mitt from 'mitt'
|
|
|
|
/** Plugin for compat with vue2 */
|
|
export default defineNuxtPlugin({
|
|
name: 'bus',
|
|
setup(nuxtApp) {
|
|
const emitter = mitt()
|
|
|
|
const once = (event, handler) => {
|
|
const wrapper = (...args) => {
|
|
handler(...args)
|
|
emitter.off(event, wrapper)
|
|
}
|
|
emitter.on(event, wrapper)
|
|
}
|
|
|
|
const bus = {
|
|
on: emitter.on,
|
|
off: emitter.off,
|
|
emit: emitter.emit,
|
|
|
|
// Vue 2 compat layer
|
|
$on: emitter.on,
|
|
$off: emitter.off,
|
|
$emit: emitter.emit,
|
|
$once: once,
|
|
}
|
|
|
|
nuxtApp.provide('bus', bus)
|
|
},
|
|
})
|