File "MessageBus.js"

Full Path: /home/fundopuh/trader.fxex.org/vendor/livewire/livewire/js/MessageBus.js
File size: 478 bytes
MIME-type: text/plain
Charset: utf-8


export default class MessageBus {
    constructor() {
        this.listeners = {}
    }

    register(name, callback) {
        if (! this.listeners[name]) {
            this.listeners[name] = []
        }

        this.listeners[name].push(callback)
    }

    call(name, ...params) {
        (this.listeners[name] || []).forEach(callback => {
            callback(...params)
        })
    }

    has(name) {
        return Object.keys(this.listeners).includes(name)
    }
}