Angular NGXS嵌套状态操作

Angular NGXS嵌套状态操作,angular,typescript,ngxs,Angular,Typescript,Ngxs,我有以下模型结构。我想根据deviceType向仪表板添加一个新的小部件 export class DeviceDashboardConfigStateModel { public deviceDashboardConfigs: DeviceExplorerDashboardConfig[]; } export class DeviceExplorerDashboardConfig { public deviceType: string; public widgets: Devic

我有以下模型结构。我想根据
deviceType
向仪表板添加一个新的小部件

export class DeviceDashboardConfigStateModel {
  public deviceDashboardConfigs: DeviceExplorerDashboardConfig[];
}

export class DeviceExplorerDashboardConfig {
  public deviceType: string;
  public widgets: DeviceExplorerDashboardWidget[];
}
有效载荷看起来像这样

export class CreateDeviceDashboardWidgetAction implements Action {
  public static readonly type: string = '[DeviceDashboard] Create Widget';
  constructor(public deviceType: string, public widget: DeviceExplorerDashboardWidget) {}
}

首先,我必须按deviceType筛选仪表板数组的所有条目,对于所选仪表板,我希望将有效负载中的小部件添加到小部件数组中。我还尝试了一些状态操作,但没有找到有效的示例。如何执行此过程

// Something like this
context.setState(
  patch({
    deviceDashboardConfigs: updateItem(dashboard => dashboard.deviceType === payload.deviceType, payload.widget)
  })
);