chancezeus / angular-laravel-echo

A Angular service for working with laravel-echo
MIT License
18 stars 21 forks source link

Error when using Pusher #3

Closed BizzyBob closed 5 years ago

BizzyBob commented 6 years ago

Hello, thank you so much for providing this package.

How can I get this working using Pusher. I've set it up according to the docs, but I get this error in the console:

Uncaught (in promise): ReferenceError: Pusher is not defined ReferenceError: Pusher is not defined

Thanks!

I'm using Angular 6 along with v2 of this package.

chancezeus commented 6 years ago

Pusher (and socket.io) are handled/used by the laravel-echo package, did you install the pusher-js package using npm install?

BizzyBob commented 6 years ago

wow, thanks for the quick response. Yes, I have the pusher-js package and laravel-echo packages installed.

chancezeus commented 6 years ago

weird, since my package only wraps laravel-echo into a angular compatible service... but I'll have a look, please give me a moment...

BizzyBob commented 6 years ago

Awesome, thanks. I'm also spinning up a fresh angular project just to further test this out.

chancezeus commented 6 years ago

Per laravel-echo docs pusher must be imported onto the window object

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

see https://laravel.com/docs/5.7/broadcasting#driver-prerequisites

I will have a look at a later time to see if there is a good way to do that from the service itself (but as far as I see in the laravel/echo service sources, the pusher connector expects an initialized object (in contrast to the socket.io connector, which expects the io constructor function) and I'd like to keep the service a simple "passthru" without too much connection specific logic)).

BizzyBob commented 6 years ago

Gotcha, thanks for looking into that. That's what I needed to know. I saw that in the Laravel documentation as well, but I did know if the service should be handling that and I was doing something wrong. Many thanks for looking into it for me. :-D