@Injectable()
export class ApiSearchEffects {
@Effect()
search$: Observable<any>
= this.actions$
.ofType(query.ActionTypes.QUERYSERVER)
.debounceTime(300)
.map((action: query.QueryServerAction) => action.payload)
.switchMap(payload => {
console.log(payload);
const nextSearch$ = this.actions$.ofType(query.ActionTypes.QUERYSERVER).skip(1);
this.searchService.getsearchresults(payload)
.takeUntil(nextSearch$)
.map((response) =>
({type: '[Search] Change', payload: response}
))
});
上面的代码给了我类型为'(payload: any) => void‘的参数,但不能将其赋给类型为'(value: any,index: number) => ObservableInput’的参数。类型'void‘不可赋值给类型'ObservableInput’。错误可能出在哪里。我在https://github.com/ngrx/effects/blob/master/docs/intro.md上关注了ngrx效果的官方介绍。
发布于 2017-06-15 15:03:53
问题是你的switchMap应该返回一个值;它返回的是你所拥有的空值。
尝尝这个
return this.searchService.getsearchresults(payload)
.takeUntil(nextSearch$)
https://stackoverflow.com/questions/44559480
复制相似问题