I have an angular 12.0.2 app that uses ngrx 12.0.0. When I run the app and access the route that lazy loads the module, I get the following error.
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(t)[t -> InjectionToken @ngrx/effects Feature Effects -> [object Object] -> t -> t -> t -> t -> t -> t]:
NullInjectorError: No provider for t!
NullInjectorError: R3InjectorError(t)[t -> InjectionToken @ngrx/effects Feature Effects -> [object Object] -> t -> t -> t -> t -> t -> t]:
NullInjectorError: No provider for t!
at fs.get (main.js:1)
I have correctly set up the ngrx and effects. Please see the code below that shows the effect. The UserService
is an entry in the provider in the module.
The error does not say which provider is missing. This is not a production build, but a build in my laptop to test.
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Observable, EMPTY, of } from 'rxjs';
import { catchError, debounceTime, map, switchMap, withLatestFrom, concatMap } from 'rxjs/operators';
import * as UserActions from '../actions/user.actions';
import { VisitorService } from '../../service/visitor.service';
import { asyncScheduler } from 'rxjs';
@Injectable()
export class UserEffects {
constructor(private actions$: Actions,
private userService: UserService) { }
loadUsers$ = createEffect(
() => ({ debounce = 300, scheduler = asyncScheduler } = {}) => {
return this.actions$.pipe(
ofType(UserActions.loadUsers),
debounceTime(debounce, scheduler),
switchMap((_) => {
return this.userService.getUserss().pipe(
map(users => (UserActions.loadUsersSuccess({ data: users }))),
catchError(err => of(UserActions.loadUsersFailure(err)))
);
})
);
});
}
EffectsModule.forFeature([UserEffects])
in the import section of the module. – Alopecia