angular - 将 @ngrx-store 移动到新版本
问题描述
我的应用程序中有@ngrx-store,现在我要将动作、减速器和效果更新到最新版本......直到现在,使用旧的动作/减速器/效果一切正常,但现在我无法从中获取数据效果,得到这个错误
错误类型错误:调度期望一个对象,而不是它收到一个函数。如果您使用 createAction 函数,请确保在调度操作之前调用该函数。例如,someAction 应该是 someAction()。
这是我的行动
import { createAction, props } from "@ngrx/store";
import { IAppAll} from "./../../app.model";
export const loadApps = createAction("[App] Load Apps");
export const loadAppsSuccess = createAction(
"[App] Load AppSuccess",
props<{ sites: IAppAll[] }>()
);
这是减速机
import { Action, createReducer, on } from "@ngrx/store";
import * as AppActions from "../actions/app.actions";
import { initialState, State } from "../state/site.model";
export const appeFeatureKey = "app";
const appReducer = createReducer(
initialState,
on(AppActions.loadApp, state => ({ ...state })),
on(AppActions.createApp, (state, { app}) => ({ ...state }))
);
export function reducer(state: State | undefined, action: Action) {
return appReducer(state, action);
}
这是效果
export class AppEffects {
loadApps$ = createEffect(() =>
this.actions$.pipe(
ofType(appActions.loadApps),
concatMap(() =>
this.appService
.getApps()
.pipe(
map((apps: IAppAll[]) => appActions.loadAppsSuccess({ apps }))
)
)
)
);
我的json是这样的
[{key: value, key1: value1},
{key: value, key1: value1}]
此数据在“最后一个”ngrx/store
版本 In action <props>
is object 上正常工作,但如何更改呢?
谢谢
解决方案
推荐阅读
- javascript - 检测到 Puppeteer 可能的 EventEmitter 内存泄漏。11 个退出侦听器添加到 [进程]
- python - 用于 bash 脚本的 Loguru 设置,用于与多个 Python 脚本一起使用
- python - 无法访问 JSON 属性
- javascript - 选择数据过滤器时如何显示项目
- java - Spring Data JPA:根据使用的 ManyToOne 字段过滤数据
- ios - 无法验证开发人员完整性,iOS 企业版
- asp.net-mvc - 提交按钮发送空白(无数据)数据 MVC ASP.Net
- mocha.js - 有没有办法将数字动态添加到摩卡的“it”块中?
- javascript - JQuery隐藏和显示具有相同类的div
- excel - Excel:如果单元格中的值与另一个选项卡上的列中的值匹配,我如何返回空白行上方的特定单元格?