Files
baserow/web-frontend/modules/core/plugins/priorityBus.js
Jérémie PardouandJonathan Adeline ca72db9a16 Nuxt3 builder fixes and cleanup (#4657)
* Fix preview error with page parameter

* Fix OIDC form support

* Fix input border color

* Fix some builder inputs

* Clear some TODO MIGs

* Clean comments

* Update snapshot

* Fix page title

* Fix reactivity issue

* refactor: replace individual RadioButtons with a RadioGroup component for choice option type selection.

* Fix domain

---------

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
2026-02-11 11:07:26 +01:00

42 lines
875 B
JavaScript

const listeners = {}
const priorityBus = {
$on(event, priority, callback) {
if (!listeners[event]) {
listeners[event] = []
}
listeners[event].push({ priority, callback })
listeners[event].sort((a, b) => b.priority - a.priority)
},
$off(event, callback) {
if (listeners[event]) {
listeners[event] = listeners[event].filter(
(listener) => listener.callback !== callback
)
}
},
$emit(event, ...args) {
if (listeners[event]) {
const highestPriorityListener = listeners[event][0]
if (highestPriorityListener) {
highestPriorityListener.callback(...args)
}
}
},
level: {
LOWEST: 1,
LOW: 2,
MEDIUM: 3,
HIGH: 4,
HIGHEST: 5,
},
}
export default defineNuxtPlugin({
name: 'priorityBus',
setup(nuxtApp) {
nuxtApp.provide('priorityBus', priorityBus)
},
})