当我试图派发可观察到的动作时,我收到下一个类型错误,如下所示:
@Effect()
rideSummary$: Observable<Action> = this.actions$.pipe(
ofType<GetRideSummary>(RideActionTypes.GetRideSummary),
map(action => action.payload),
switchMap(payload => {
const { ride, passenger } = payload;
const allPassengers = [...ride.passengers, passenger];
this.store.dispatch(new SetLoading);
return this.directionService.computeRideRouteSummary(ride, allPassengers)
.then((summary: RideRouteSummary) => {
const updatedRoute = Geometry.newFromData({
type: Geometry.LINE_STRING,
coordinates: summary.route
});
const totalTime = summary.totalTime;
const arrivalTime = ride.type === Ride.TYPE_TOWORK ?
ride.hour :
ride.hour + summary.totalTime;
const departureTime = ride.type === Ride.TYPE_TOWORK ?
ride.hour - summary.totalTime :
ride.hour;
this.store.dispatch(new UnsetLoading);
return this.store.dispatch(new GetRideSummarySuccess({
updatedRoute,
totalTime,
arrivalTime,
departureTime
}));
}
).catch(error => {
this.store.dispatch(new UnsetLoading);
catchError(() => of(new HandleError(error)));
});
})
);
类型错误提示:
Unable to assign an argument of type "(payload: {ride: Ride; passenger: Passenger;}) => void" to the type parameter "(value: {ride: Ride; passenger: Passenger;}, index: number) => ObservableInput <Action> ".
The type 'void' can not be assigned to the type 'ObservableInput <Action>'.
我不确定代码有什么问题。似乎与promise
有关。有什么帮助吗?
答案 0 :(得分:0)
效果定义为from flask import Flask
from flask.ext.bcrypt import Bcrypt
,表示期望@Effect()
。
快速但肮脏的解决方法是将效果定义为Action
。
更合适的解决方法是删除所有影响您的商店的发货并返回操作。
一个简单的例子是:
@Effect({dispatch: false})
收件人:
switchMap(payload => {
this.store.dispatch(new FooBar());
}