如何使用 ngrx 存储在不调用 api 的情况下更新状态数据?

发布于 2025-01-17 19:25:19 字数 381 浏览 0 评论 0原文

我有一个用户列表,我希望能够更新每个用户的详细信息(在模式中)并将其保持在状态(没有 API 调用进行更新)。我正在尝试用效果来做到这一点,但我不确定实现它的正确方法是什么。

操作:

减速器:

用户详细信息

在此处输入图像描述

I have a users list and I want to be able to update each user's details (in a modal) and keep them in the state(no API call for update). I'm trying to do this with effects but I'm not sure what is the correct way to achieve it.

Actions:

Reducer:

User details

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囍笑 2025-01-24 19:25:19

如果您不需要提出API请求(或没有副作用),则不需要效果。
在您的情况下,模态派遣了一个操作,而还原器会倾听该操作并更新状态。

You don't need an effect if you don't need to make an API request (or if there's no side effect).
In your case, the modal dispatches an action, and the reducer listens to that action and updates the state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文