这是我第一次使用switchMap。它告诉我要返回"something",但是当我返回一个return时,它就不起作用了。
@Effect()
subData$ = this.actions$.pipe(
ofType(ActionTypes.SEARCH_SUB_DATA),
map(action => action['payload']),
switchMap(payload => { //Payload gets highlighted in red
const repos = this.githubSearch.getRepos(payload);
const followers = this.githubSearch.getFollowers(payload);
const starred = this.githubSearch.getStarred(payload);
return forkJoin([repos, followers, starred]).subscribe(results => {
this.store.dispatch(
new UserActions.SuccessSubData({
user: payload,
repos: results[0],
followers: results[1],
starred: results[2]
})
);
return of(results);
});
})
);‘(
:never) => Subscription’类型的参数不能分配给类型为'(value: never,index: number) => ObservableInput<{}>‘的参数。类型'Subscription‘不能赋值给类型'ObservableInput<{}>’。
基于提供的答案的更新
@Effect()
subData$ = this.actions$.pipe(
ofType(ActionTypes.SEARCH_SUB_DATA),
map(action => action['payload']),
switchMap(payload => {
return forkJoin(
this.githubSearch.getRepos(payload),
this.githubSearch.getFollowers(payload)
);
}).subscribe(results => {
this.store.dispatch(
new UserActions.SuccessSubData({
user: payload,
repos: results[0],
followers: results[1]
})
);
})
);下面的图片显示了错误
https://stackoverflow.com/questions/56265751
复制相似问题