我试图弄清楚@ngrx/effects 是如何工作的,但是在我的错误和我的 stackbliz 代码下面的这个简单示例中我遇到了一些问题
https://stackblitz.com/edit/redux-in-actions?file=src%2Fapp%2Fstore%2Feffects%2Ftask.effects.ts
Type 'Observable' is not assignable to type 'Observable'. Type 'void' is not assignable to type 'Action'
谢谢
最佳答案
在 RXJS 中,在 map 操作符中,您需要在观察者订阅时将收到返回值。
@Effect()
loadTasks$: Observable<Task[]> = this.actions$
.ofType(fromActions.ADD_TASK).pipe(
switchMap(() => ({this.taskService.GetTasks().map(data => {
return data; })
}))
);
关于Angular ngrx@effect 基本问题 : Type 'Observable<void>' is not assignable to type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53638204/