i have NgRX effect class which i think is almost the same as in docs.
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { EMPTY } from 'rxjs';
import { map, mergeMap, catchError } from 'rxjs/operators';
import { SocialLearningFacadeService } from '../../facades/social-learning-facade.service';
import { loadCategories, retreivedCategories } from '../actions/categories';
@Injectable()
export class CategoriesEffects {
loadMovies$: any = createEffect((): any =>
this.actions$.pipe(
ofType(loadCategories),
mergeMap(() =>
this.socialLearningFacadeService.getSocialLearningCategories().pipe(
map((categories) =>
retreivedCategories({ socialLearningCategories: categories })
),
catchError(() => EMPTY)
)
)
)
);
constructor(
private actions$: Actions,
private socialLearningFacadeService: SocialLearningFacadeService
) {}
}
my actions:
import { createAction, props } from '@ngrx/store';
import type { SocialLearningCategory } from '../../../../core/models/socialLearningCategory';
export const loadCategories = createAction('load categories');
export const retreivedCategories = createAction(
'retreived social learning categories',
props<{ socialLearningCategories: any }>()
);
and there is this error on MergeMap:
I have no clue how to interprete this error, espacially that my example is very similar to the docs one and still doesn't work.
EDIT: Social learning facade service
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { SocialLearningService } from '../services/social-learning.service';
import type { SocialLearningCategory } from '../../../core/models/socialLearningCategory';
import type { SocialLearningCategoryDetails } from '../../../core/models/socialLearningCategoryDetails';
@Injectable({
providedIn: 'root',
})
export class SocialLearningFacadeService {
constructor(private socialLearningService: SocialLearningService) {}
public getSocialLearningCategories(): Observable<SocialLearningCategory[]> {
return this.socialLearningService.getSocialLearningCategories();
}
public getSocialLearningCategoryDetails(
id: number
): Observable<SocialLearningCategoryDetails> {
return this.socialLearningService.getSocialLearningCategoryDetails(id);
}
}