I am using the below versions:
@ngrx/core@1.2.0
@angular/cli@8.3.25
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'.
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