angular - @ngxs-labs/data / @angular-ru/ngxs 一对多关系架构
问题描述
有没有人有使用 NGXS 或事件更好的示例 @ngxs-labs/data 包,现在位于 @angular-ru/ngxs 相关数据来自 N 个不同的 API 调用,但需要使用单个 ID 进行查询?
我从后端收到的父/主模型如下所示:
Application
-Id
-Name
-Etc...
但是在与应用程序页面相同的页面上,我还必须查询从 API 接收到的提交或日志:
Commits
-Id
-ContributorName
-Etc...
Logs
-Id
-Format
-Etc...
我的问题是能够在给定应用程序 ID 的情况下选择那些提交或日志,其好处是仍然使用来自 NGXS 数据等的实体状态运算符助手(如在任何实体状态管理器中,如 @ngrx/entity 包addOne
)removeOne
......我不想陷入不得不自己完成所有这些操作的陷阱,就像我过去对扩展运算符和其他东西所做的那样。
目前我的提交状态如下所示:
export interface EntityStateDictionnary<T> {
[key: string]: Dictionary<T>
}
const applicationCommitsInitialState: EntityStateDictionnary<ApplicationCommit[]> = {
commits: null,
}
this.patchState({
commits: {
...this.getState().commits,
[`${appId}`]: applicationCommits,
},
})
知道应用程序模型有 20 多个与之相关的 API 调用,您将如何构建给定这些模型的商店?
解决方案
推荐阅读
- html - Safari 表行渐变背景重复错误
- visual-studio-mac - Visual Studio crashes when trying to open an existing project
- swift - Swift“更改数组中的项目” Noobie in swift
- vba - 在公共函数中修改表单属性
- javascript - Javascript:如何在代码块之间传输变量?
- azure - 是否可以在 Azure Vault 中生成公钥私钥对
- javascript - 如何在 Vue.js/Nuxt.js 中播放单个视频时暂停所有其他视频?
- c++ - 创建一个 1000 个整数的 std::initializer_list,默认值为 5
- python - 如何将文件和list_of_strings作为python中的命令行参数进行搜索
- javascript - 如何从 forEach 循环中仅选择一项并取消选择其他项?