vendredi 26 octobre 2018

Laravel Pusher not pushing (but Pusher receiving fine)

I need to push to Pusher a string and get it to push on the Vue app, so this is what I did:

(setup env file with Pusher credentials)

Created a VideoUpdated event with:

public function broadcastOn()
{
    return new Channel('channelDemoEvent');
}

Set bootstrap.js with Echo and Pusher setup:

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: false
});

Then app.js with Vue:

require('./bootstrap');

const app = new Vue({
    el: '#app',
    data() {
        return {
            name: 'Andy'
        }
    },
    mounted() {
        Echo.channel('channelDemoEvent').listen('App\Events\VideoUpdated', (e) => {
            alert("event");
        })
    }
})

And the view:

The blade page renders variable fine:

@extends('layouts.app')

@section('content')
   Ciao @ !
@endsection

The Pusher app is receiving fine:

enter image description here

But no event fires in the blade view. What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire