DVLP / signalr-no-jquery

120 stars 77 forks source link

Using with Angular2 #5

Closed AbrarJahin closed 4 years ago

AbrarJahin commented 7 years ago

Hi, I like to use it with Angular2.

Is there any way of doing that?

Is there any example from which I can see demo code for that?

Thanks

sateffen commented 7 years ago

Yould you specify, what problem you've got with the integration in angular2?

The usual way of integrating this lib in angular2 would be to implement one service for managing the connection and a couple of other services, using the first one and providing the different hubs.

Maybe I've got some sparetime at some weekend to build a little example gist, without angular2 integration, but giving an idea of how to use signalR.

AbrarJahin commented 7 years ago

If you can give a example code, that would be great help.

Thanks @sateffen

sateffen commented 7 years ago

@AbrarJahin A basic example can be found here in the readme. I'm currently testing an own version of a jqueryless signalr, which contains the correct signalr version (not on npm yet, nor tested anywhere).

You can use the code as it stands, just replace const signalR = require('jqueryless-signalr'); with const signalR = require('signalr-no-jquery').hubConnection;

That might not be angular2 specific code, but adapting that one for an angular2 service should be trivial.

ghost commented 6 years ago

This is an Example how to use is with angular 5:

SignalR Service

image

Environment

image

AbrarJahin commented 6 years ago

Thanks to you both @sateffen @BissacM

itsthetaste commented 6 years ago

I also needed to add the types like this npm install --save @types/signalr-no-jquery and also I didn't need the new on the hubConnection