angular - 类型'可观察的' 不可分配给类型 'EffectResult'
问题描述
完整代码取自documentaion:
import { Injectable } from "@angular/core";
import { Actions, createEffect, ofType } from "@ngrx/effects";
import { of } from "rxjs";
import { map, mergeMap, catchError } from "rxjs/operators";
@Injectable()
export class RegistryEffects {
loadMovies$ = createEffect(() =>
this.actions$.pipe(
ofType("load"),
mergeMap(() =>
this.moviesService.getAll().pipe(
map((movies) => ({
type: "loaded_success",
payload: movies,
})),
catchError(() => of({ type: "loaded_error" }))
)
)
)
);
constructor(private actions$: Actions, private moviesService: any) {}
}
我收到此错误消息:
类型“Observable”不可分配给类型“EffectResult”。类型“Observable”不可分配给类型“Observable”。'{}' 类型中缺少属性 'type',但在 'Action'.ts(2322) 类型中需要属性'type':此处声明了'type'。effect_creator.d.ts(42, 161):预期类型来自此签名的返回类型。
如何修复它,我的 Redux 出了什么问题?
解决方案
推荐阅读
- javascript - 如何在旧的三星电视上进行 api 调用?
- python - 使用 pandas 在 SQlite 中导入 excel 文件
- c# - 自定义授权属性 [CustomAuthorize] 不适用于 Blazor asp.net core 5
- angular - distinctUntilChanged 不适用于与以前相同的值
- php - Mercure - 401 与令牌提供程序
- python - 列表python中子列表中元素的索引
- r - 根据最大值缩放数字
- java - 如何通过 Java 17 中的反射获取所有 Record 字段及其值?
- kendo-ui - 如何使用静态 HTML 标记作为视图,而不是在 Kendo 滚动视图中使用数据
- inno-setup - Inno Setup:在卸载程序的 UAC 提示中替换“设置/卸载”字符串