ng2-signalr: Calling function 'SignalRModule', function calls are not supported.
I’m using the Angular-cli to make a very basic “Hello world” app with SignalR using your module, and I keep getting this:
ERROR in Error encountered resolving symbol values statically. Calling function 'SignalRModule', function calls are not supported. Consider replacing the function
or lambda with a reference to an exported function, resolving symbol AppModule in C:/code/Ang2SR/src/app/app.module.ts, resolving symbol AppModule in C:/code/Ang2S
R/src/app/app.module.ts
webpack: Failed to compile.
My app.module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { EchoComponent } from './echo/echo.component';
import { signalrConfiguration } from './app.config';
import { SignalRModule, SignalRConnection, ConnectionStatus, BroadcastEventListener } from 'ng2-signalr';
@NgModule({
declarations: [
AppComponent,
EchoComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SignalRModule.configure(signalrConfiguration)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.config.ts:
import { SignalRConfiguration } from 'ng2-signalr';
const signalrConfig = new SignalRConfiguration();
signalrConfig.hubName = 'echoHub';
signalrConfig.qs = { user: 'Hannes' };
signalrConfig.url = 'http://localhost:44369/signalr/hubs';
export const signalrConfiguration = signalrConfig;
Has this got something to do with publishing metadata/AoT? Any ideas?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 37 (23 by maintainers)
issue fixed in v2.0.0
Ok, as none of the temporary fixes seemed to work for me, in order to build I’ve done the following in order to get things working. I absolutely do not suggest this fix, but if you just desperately need it to work, this does. Essentially I’ve entirely bypassed using the “SignalRModule” from ng2-signalr entirely, and just gone around it and that fixes the problem.
First off I cloned the repo from here rather than used “npm install ng2-signalr” as I needed the typescript. Then I moved that module into my app work space for ease of use.
in your app.module.ts, remove
SignalRModule.configure(configuration)from your imports, and in providers, addand at the top import them from the new module directory. E.g.:
At this point you might want to move everything out of “lib” so that everything is just under ng2-signalr as opposed to “ng2-signalr/src”. Then in the new module, go into the signalr.ts and replace the constructor to this and add these three methods:
Now I’ve put my config in a file called “app.config.ts”, which you can still use in this scenario:
I’ve been handling all the SignalR interactions in my app inside a service. In this service, in the constructor, I’ve added a call to the “configure” method we just added in _signalR:
So obviously the problem for us lies with the SignalRModule, as just bypassing it all together and leaving everything else fine allows everything to work just fine. This obviously isn’t a permanent fix, but perhaps you can make something of this @HNeukermans .
The long awaited fix in on the way. I already merged in the request. Still need to publish it to npm and update the readme of the breaking change… Thx to @dylabar and @DaveMonag.
…some patience
I have this issue !! But I read this topic and don’t get solution Please explain me the solution step by step, thanks
@DaveMonag The “getSignalRConfiguration” function is the name of the forRoot parameter. In the second code snippet, I use the function “createSignalRConfiguration” and pass it in as this parameter. Therefore I believe the function you’re looking for is actually the createSignalRConfiguration function.
Hi DaveMonag,
not yet. Focussing on test coverage for the moment…
Apparently, this feature is highly requested… Will need to look into…
@cinkpen both ng2-signalr.demo.webui.systemjs and ng2-signalr.demo.webui can help you out. I’m working on the documentation. It is still work in progress though http://ng2-signalr-webui.azurewebsites.net/
Hi zareone,
thx for liking the library. I’ve looked into the AOT issue… but I need more time to investigate as I am new to AOT and have difficulty in understanding the errors that come with it. Good news there is a workaround. #9. I’ m currently giving priority to working on my live demo and code documentation. If someone knows how to fix the AOT issue, I’ll be glad to merge it in…,
I’m on v1.0.5 now and the update hasn’t changed the error. (**See edit) I was also having another problem at the same that I forgot to include - when attempting a connect:
Might be related.
Also in your ReadMe in the “How to listen for server side events” section you reference “this.connection” but that isn’t mentioned anywhere else. Where/how should I define connection? At the moment I’m trying this:
Which when added, started the original error.
EDIT: Fixed the JQuery error, I hadn’t imported the scripts into my angular-cli.json:
The SignalRModule error still persists though.