NGRX还原器集数组到对象内的内部
我的存储对象结构如下所示,
{
"fooObject":[
{
"id":1,
"somefield":"bla bla",
"orderArray":[
{
"id":1,
"somefield":"a"
},
{
"id":2,
"somefield":"b"
},
{
"id":3,
"somefield":"c"
}
]
}
]
}
我需要使 orderaray 在NGRX还原器上为空。而且只需要更改该数组即可。我试图跟随以获得所需的行为,但没有成功。我也尝试使用地图方法,但它失败了。
on(ProductionLineAction.successSetInitialStateScheduledOrderLine, (state, action) => {
return {
...state,
fooObject: [
...state.productionLinesDisplayDetails,
{
orderArray: action.scheduledOrders
}
]
}
}),
I have Store object structure as follows
{
"fooObject":[
{
"id":1,
"somefield":"bla bla",
"orderArray":[
{
"id":1,
"somefield":"a"
},
{
"id":2,
"somefield":"b"
},
{
"id":3,
"somefield":"c"
}
]
}
]
}
I need to make the orderArray empty on the NGRX reducer. and only need to change that array. I attempted to following to obtain my desired behavior but was unsuccessful.I tried using the Map method as well, but it failed.
on(ProductionLineAction.successSetInitialStateScheduledOrderLine, (state, action) => {
return {
...state,
fooObject: [
...state.productionLinesDisplayDetails,
{
orderArray: action.scheduledOrders
}
]
}
}),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还原器将冻结状态树中的所有对象,因此您必须创建一个具有新数据副本的新数组。
The reducer will have frozen all the objects in the state tree so you'll have to create a new array with a new copy of the data.