我在switchMap运算符中有错误:
@Injectable()
export class AvailableStoreTypesLoadedEffect {
constructor(private actions$: Actions,
private service: AvailableService) {
}
@Effect()
AvailableStoreTypesLoadedEffect$ = this.actions$
.ofType(FETCH_AVAILABLE_STORE_TYPES)
.pipe(
switchMap(action => this.service.fetchAvailableStoreTypes()),//Error:(22, 9) TS2684:The 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'.
map(res => new AvailableStoreTypesLoaded(res))
);
}
Run Code Online (Sandbox Code Playgroud)
我尝试过:
Observable.of({})
.pipe(
switchMap(() => Observable.of({}))//Error:(22, 9) TS2684:The 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'.
);
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误.
我的环境是:
yam*_*dvo 11
我从中导入了库,import { mergeMap } from 'rxjs/operator/mergeMap';但必须从中导入import { mergeMap } from 'rxjs/operators';
| 归档时间: |
|
| 查看次数: |
1182 次 |
| 最近记录: |