1
votes

I am using the below versions:

imports:

import { BookService } from './../services/book.service';
import {Actions, Effect, ofType} from '@ngrx/effects';
import {mergeMap, map} from 'rxjs/operators';
import {Action} from '@ngrx/store';
import * as types from './action.types';
import * as bookActions from './book.actions';

constructor:

constructor(private service: BookService,
        private actions$: Actions){}

@Effect() loadBooks$: Observable<Action> = this.actions$.pipe(
        ofType<bookActions.loadBooksAction>(types.LOAD_BOOKS),
        mergeMap(() => 
            this.service.getAllBooks().pipe(map(books => 
                new bookActions.loadBooksSuccessAction(books)))
        )
    )

The Error: Property 'pipe' does not exist on type 'Actions'.

2
Please share your imports, I think there is the error. - Anarno
Ok, pls show your constructor too. - Anarno
updated in the question - Comraid

2 Answers

0
votes

First thing ngrx v8 use new syntax so you may want to check it with your code

Sample from the docs

search$ = createEffect(() => ({
  // assign default values
  debounce = 300,
  scheduler = asyncScheduler
} = {}) =>
  this.actions$.pipe(
    ofType(BookActions.search),
    debounceTime(debounce, scheduler),
    ...
  )
);

Secondly remove package-lock.json and @ngrx/core package (no need for this) in your package.json

And update package.json like this

"@ngrx/effects": "^8.6.0",
"@ngrx/store": "^8.6.0",
"@ngrx/store-devtools": "^8.6.0",

Then run

npm cache clean --force
npm i 

You can delete node_modules folder and run npm i if the problem still exist

1
votes

The problem is the dependency @ngrx/[email protected]. It's an old version and deprecated package for ngrx.

You have to remove it.