如何从另一个对象 ngrx 更新一个对象的 属性
How to update an object's property from another object ngrx
我有这个状态
interface ILeadsPageState {
leadsList : LeadBasicDto[]
isLoading : boolean;
error : any;
}
export interface ILeadsState {
leadsListPage : ILeadsPageState
}
//--------------------------------------------------------------------------------------
// State Initialization
//--------------------------------------------------------------------------------------
export const InitialLeadsState: ILeadsState = {
leadsListPage : {
leadsList : [],
isLoading : true,
error : null
}
};
我的减速机是:
const leadsReducer = createReducer(
InitialLeadsState,
on(actions.loadLeads, (state) => **({ ...state, XXXXXXXXX }))**,
);
如何修改动作 loadLeads 上的 isLoading 属性,我找不到任何方法。
on(actions.loadLeads, (state) =>
({ leadsListPage : { ...state.leadsListPage, isLoading: false } })),
或者直接使用ngrx-immer
immerOn(actions.loadLeads, (state) => {
state.leadsListPage.isLoading = false
}
我有这个状态
interface ILeadsPageState {
leadsList : LeadBasicDto[]
isLoading : boolean;
error : any;
}
export interface ILeadsState {
leadsListPage : ILeadsPageState
}
//--------------------------------------------------------------------------------------
// State Initialization
//--------------------------------------------------------------------------------------
export const InitialLeadsState: ILeadsState = {
leadsListPage : {
leadsList : [],
isLoading : true,
error : null
}
};
我的减速机是:
const leadsReducer = createReducer(
InitialLeadsState,
on(actions.loadLeads, (state) => **({ ...state, XXXXXXXXX }))**,
);
如何修改动作 loadLeads 上的 isLoading 属性,我找不到任何方法。
on(actions.loadLeads, (state) =>
({ leadsListPage : { ...state.leadsListPage, isLoading: false } })),
或者直接使用ngrx-immer
immerOn(actions.loadLeads, (state) => {
state.leadsListPage.isLoading = false
}