围绕我的 State Store 设计进行推理 - UI vs App State
Reasoning around my State Store Design - UI vs App State
我对应用程序状态和 UI 状态感到有点困惑。当用户从页面上的列表中选择 activity 时,将进行 API 调用以获取所选 activity 的公告。选择的activity id 是考虑UI 还是应用状态?选定的 activity id 应该存储在 sale-activity 切片中还是应该进入专用的 UI 切片,例如 sale-activity-listing?
这是我当前的结构。
{
"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
}
我不知道在这种情况下应用程序和 ui 状态之间是否真的存在分离——对我来说都是 "ui application" 状态。不过,我认为您的结构没有任何问题。
我对应用程序状态和 UI 状态感到有点困惑。当用户从页面上的列表中选择 activity 时,将进行 API 调用以获取所选 activity 的公告。选择的activity id 是考虑UI 还是应用状态?选定的 activity id 应该存储在 sale-activity 切片中还是应该进入专用的 UI 切片,例如 sale-activity-listing?
这是我当前的结构。
{
"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
}
我不知道在这种情况下应用程序和 ui 状态之间是否真的存在分离——对我来说都是 "ui application" 状态。不过,我认为您的结构没有任何问题。