@Injectable()
export class LoadUserThreadsEffectService { constructor(private action$: Actions, private threadsService: ThreadsService) {
} @Effect()
userThreadsEffect$: Observable<Action> = this.action$
.ofType(LOAD_USER_THREADS_ACTION)
.switchMap((action) => this.threadsService.loadUserThreads(action.payload))
.map((allUserData) => new LoadUserThreadsSuccess(allUserData)); @Effect()
userSelectedEffect$: Observable<Action> = this.action$
.ofType(USER_SELECTED_ACTION)
.map((action) => new LoadUserThreadsAction(action.payload))
}
For the first Effect,
LOAD_USER_THREADS_ACTION
will trigger another action:
.map((allUserData) => new LoadUserThreadsSuccess(allUserData));
Second effect:
.ofType(USER_SELECTED_ACTION)
will trigger another action:
.map((action) => new LoadUserThreadsAction(action.payload))