mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Turn event bus into a class
This commit is contained in:
parent
98b1252c68
commit
60d95e95de
2 changed files with 7 additions and 12 deletions
|
@ -16,7 +16,6 @@ new Vue({
|
|||
el: '#app',
|
||||
render: h => h(App),
|
||||
created () {
|
||||
event.init()
|
||||
http.init()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -53,21 +53,15 @@ export function isMediaSessionSupported () {
|
|||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const event = {
|
||||
bus: null,
|
||||
|
||||
init () {
|
||||
if (!this.bus) {
|
||||
this.bus = new Vue()
|
||||
}
|
||||
|
||||
return this
|
||||
},
|
||||
class EventBus {
|
||||
constructor () {
|
||||
this.bus = new Vue()
|
||||
}
|
||||
|
||||
emit (name, ...args) {
|
||||
this.bus.$emit(name, ...args)
|
||||
return this
|
||||
},
|
||||
}
|
||||
|
||||
on () {
|
||||
if (arguments.length === 2) {
|
||||
|
@ -80,4 +74,6 @@ const event = {
|
|||
}
|
||||
}
|
||||
|
||||
const event = new EventBus()
|
||||
|
||||
export { event }
|
||||
|
|
Loading…
Reference in a new issue