相关疑难解决方法(0)

如何同时调度多个 ngrx 动作

我正在使用 ngrx 并且有一个场景,我需要同时调度 2 个动作。我的状态具有用于更新和更新的属性,如下所示。

//from reducer
const defaultCardState: CardState = {
    ids: [],
    entities: {},
    loaded: false,
    loading: false,
    adding: false,
    added: false,
    updating: false,
    updated: false,
    deleting: false,
    deleted: false
};
Run Code Online (Sandbox Code Playgroud)

这些是我从我的组件分派的动作

this.store.dispatch(fromCard.updateCard({id: id1, changes: {name: name1}}))
this.store.dispatch(fromCard.updateCard({id: id2, changes: {name: name2}}))
Run Code Online (Sandbox Code Playgroud)

下面是我的动作,减速器和效果

//Update Card Actions
export const updateCard = createAction('[Cards] Update Card', props<{id: string, changes: any}>())
export const updateCardSuccess = createAction('[Cards] Update Card Success', props<{changes: any}>());
export const updateCardFail = createAction('[Cards] Update Card Fail')

//Reducer
on(fromCards.updateCard, (state) …
Run Code Online (Sandbox Code Playgroud)

rxjs typescript redux ngrx angular

2
推荐指数
1
解决办法
2880
查看次数

标签 统计

angular ×1

ngrx ×1

redux ×1

rxjs ×1

typescript ×1