While working with NgRX 8 my colleagues and me are frequently facing a weird error message when implementing the effects.
Type \'Observable
In case of dealing with this problem and using official ngrx 8 example.
loadMovies$ = createEffect(() => this.actions$.pipe(
ofType('[Movies Page] Load Movies'),
mergeMap(() => this.moviesService.getAll()
.pipe(
map(movies => ({ type: '[Movies API] Movies Loaded Success', payload: movies })),
catchError(() => EMPTY)
))
)
);
Easy and fast solution can be putting "any" type.
loadMovies$: any = createEffect((): any => this.actions$.pipe(
ofType('[Movies Page] Load Movies'),
mergeMap(() => this.moviesService.getAll()
.pipe(
map(movies => ({ type: '[Movies API] Movies Loaded Success', payload: movies })),
catchError(() => EMPTY)
))
)
);
Do not forget imports for rxjs operators, observables.
In case of dealing with action payload - props, define an action type.
ofType
or
ofType>