Complete the code to import the EffectsModule in Angular.
import { [1] } from '@ngrx/effects';
The correct import is EffectsModule from '@ngrx/effects'.
Complete the code to create an effect that listens for a 'loadItems' action.
loadItems$ = createEffect(() => this.actions$.pipe(ofType([1]), /* side effect here */));The ofType operator listens for the exact action name, which is loadItems.
Fix the error in the effect to correctly dispatch a new action after a side effect.
loadItems$ = createEffect(() => this.actions$.pipe(ofType(loadItems), switchMap(() => this.api.getItems().pipe(map(items => [1])))));The correct way to dispatch an action with payload is calling the action creator with an object: loadItemsSuccess({ items }).
Fill both blanks to create an effect that handles errors by dispatching a failure action.
loadItems$ = createEffect(() => this.actions$.pipe(ofType(loadItems), switchMap(() => this.api.getItems().pipe(map(items => loadItemsSuccess({ items })), [1](error => of([2]))))));Use catchError to catch errors and dispatch loadItemsFailure with the error.
Complete the code to define an effect that does not dispatch any action but performs a side effect.
logAction$ = createEffect(() => this.actions$.pipe(ofType(logEvent), tap(() => console.log('Event logged'))), { {{BLANK_1}: false,} });Set dispatch: false in the effect options object to indicate no action is dispatched.