围绕我的State Store Design推理 - UI与App State

时间:2018-01-10 15:22:52

标签: javascript angular redux ngrx ngrx-store

我在应用程序状态和UI状态之间有点混淆。当用户从页面上的列表中选择活动时,将进行API调用以获取所选活动的通知。所选活动ID是UI还是应用程序状态?所选活动ID是否应存储在销售活动切片中,还是应该进入专用UI切片,例如销售活动列表?

这是我目前的结构。

{
    "entities": {
        "sale-activities": {
            "1": { "id": 1, "vehicleId": 3, "status": "pending" },
            "2": { "id": 2, "vehicleId": 3, "status": "completed" }
        },
        "sale-activity-announcements": {
            "4": { "id": 1, "saleActivityId": 1, "description": "Announcement 4" },
            "5": { "id": 2, "saleActivityId": 1, "description": "Announcement 5" },
            "6": { "id": 1, "saleActivityId": 2, "description": "Announcement 6" },
            "7": { "id": 2, "saleActivityId": 2, "description": "Announcement 7" }
        }
    },
    "sale-activities": {
        "loaded": true,
        "loading": false,
        "ids": [1, 2],
        "offset": 0,
        "selectedActivityId": 1
    },
    "sale-activity-announcements": {
        "1": {
            "loaded": true,
            "loading": false,
            "ids": [4, 5]
        },
        "2": {
            "loaded": true,
            "loading": false,
            "ids": [6, 7]
        }
    },
    "selectedVehicleId": 3
}

1 个答案:

答案 0 :(得分:0)

我不知道在这种情况下,应用程序和ui状态之间真的存在分离 - 它是所有应用程序"对我说。我认为你的结构没有错。