channel.bind from pusher give me infinite loop

Posted 8 months ago by jahstation

Im a very beginner in js world... anyway Im trying to integrate this js lib on html page that contains even a "pusher" function for loading data from a channel (laravel broadcasted event). - the final goal is a real time typing-txt to be seen on a screen- So I've the script like this in my blade page:

var pusher = new Pusher('xxxxxxxxxxxx', { cluster: 'xxxx', forceTLS: true });

var channel = pusher.subscribe('xxxxx');

var options = {
    strings: ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
    typeSpeed: 80

var typed = new Typed(".element1", options);

channel.bind('App\Events\TextAdded', function(data) {
    var txt = JSON.stringify(data.testo);
    var typed2 = new Typed('.element', {
        strings: [txt],
        typeSpeed: 80


the first inizialazed outside the "channelbind" part of Typed works well...

then at the first event the inside part of works good, after at every next event the Typed declaration goes in pain and start to write and cancel his sentence every second, without hope to stop it without reloading the page manually... memba that var txt = JSON.stringify(data.testo); helps me to make this part works at least the first time, otherwise even the very first event went in pain.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.