I'm currently attempting to create an Ngrx effect that can retrieve posts from several users instead of just one. I have successfully implemented an effect that loads posts from a single user, and now I want to split the LoadUsersPosts effect into individual LoadUserPosts effects for each user. How can I achieve this?
This is my current approach:
@Effect() loadUsersPosts$ = this.actions$
.ofType(LOAD_USERS_POSTS)
.mergeMap((action: LoadUsersPosts) => {
const array = [];
action.payload.forEach(user => {
array.push(new LoadPosts(user));
});
return array;
});
Despite inserting console.log's within the forEach loop, it appears that the code isn't being executed at all.