我的应用程序中有@ ngrx-store,现在我要将动作,减速器和效果更新到最新版本...直到现在,使用旧的动作/减速器/效果,一切正常,但是现在我不能从效果中获取数据,得到此错误
错误TypeError: 派发预期的对象,而是接收一个函数。 如果您使用的是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
版本上正常工作
action <props>
中有对象,但是如何更改呢?
thnx