src/View.php
public function jsVueEmit($eventName, $eventData = [])
    {
        // adding this view id to data.
        // Usually, you would check if the event is emit for the right component.
        if (!$eventData['id']) {
            $eventData['id'] = $this->name;
        }

        return (new jsVueService())->emitEvent($eventName, $eventData);
    }
public function jsVueEmit($eventName, $eventData = [])
    {
        // adding this view id to data.
        // Usually, you would check if the event is emit for the right component.
        if (!$eventData['id']) {
            $eventData['id'] = $this->name;
        }

        return (new jsVueService())->emitEvent($eventName, $eventData);
    }
public function jsVueEmit ( $ eventName , $ eventData = [ ] ) { // adding this view id to data. // Usually, you would check if the event is emit for the right component. if ( ! $ eventData [ 'id' ] ) { $ eventData [ 'id' ] = $ this -> name ; } return ( new jsVueService ( ) ) -> emitEvent ( $ eventName , $ eventData ) ; }
Emit an event on the Vue event bus.
vueService has a dedicated Vue instance for registering
event that allow communication between external view like button,
or even separate vue component, in order to communicate to each other.

Once a component is set for listening to a particular event,
you can emit the event using this function.

Adding a listener is generally done via the created component method.

example of adding a listener inside the created method.

atk.vueService.eventBus.$on('eventName', (data) => {
// make sure we are talking to the right component.
if (this.$parent.$el.id === data.id) {
this.doSomething();
}
});


@param string $eventName The event name the will be emit.
@param array  $eventData $eventData   The data passed with the event.

@return mixed
Emit an event on the Vue event bus . vueService has a dedicated Vue instance for registering event that allow communication between external view like button or even separate vue component in order to communicate to each other .