Working with @ngrx/effects
version 4.0.5 alongside Angular version 4.4.4.
An issue arises when incorporating EffectsModule
into the app.module.ts
file, causing the Http service to become undefined.
Snippet of relevant code:
// app.module.ts
import { BrowserModule, Title } from '@angular/platform-browser';
...
import { HttpModule, Http } from '@angular/http';
...
import { EffectsModule } from '@ngrx/effects';
import { AuthenticationModule } from './authentication/authentication.module';
import { MyEffects } from './myEffects.ts'
...
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpModule,
...
AuthenticationModule,
StoreModule.forRoot(reducers),
EffectsModule.forRoot([MyEffects])
]
...
})
export class AppModule { }
Note that MyEffects
is not associated with the authentication functionality.
Upon attempting to use the sign in feature of my app by calling AuthenticationService.signIn, which internally calls its http instance this.http.post(...
, I encountered an error due to this.http
being undefined. Further investigation revealed that although this
exists, its http
property is undefined as well.
If I disable
EffectsModule.forRoot([MyEffects])
, the Http service functions properly and allows successful sign in operations.
Note again that MyEffects
does not impact the authentication mechanism.