我正在尝试使用ngrx
rxjs
运算符集成withLatestFrom
缓存。但是出现错误:
You provided 'undefined' where a stream was expected.
You can provide an Observable, Promise, Array, or Iterable.
有人纠正我的密码吗?
这是我的代码:
@Effect()
EffLoadCourse = this.actions.pipe(
ofType(LoadCourse.TYPE),
withLatestFrom(
this.store.pipe(select(subscribes.getCourses)), //getting it from store
(action: LoadCourse, courses: ModelCourse[]) => {
// console.log('action is ', action, 'courses is', courses)
return courses;
}
),
mergeMap((courses: ModelCourse[]) => {
if (courses) { //if courses available just return it
map((courses: ModelCourse[]) => (new LoadCourseSuccess(courses))),
catchError(err => of(new LoadCourseFail(err)))
return;
}
//only return on courses unavailability
return this.courseService.getCourse().pipe(
map((courses: ModelCourse[]) => (new LoadCourseSuccess(courses))),
catchError(err => of(new LoadCourseFail(err)))
)
})
)
答案 0 :(得分:1)
if(courses){ //if courses available just return it
map((courses:ModelCourse[]) => (new LoadCourseSuccess(courses))),
catchError(err => of(new LoadCourseFail(err)))
return;
}
您没有返回任何动作,只是一个void