如何使用 ngrx 存储在不调用 api 的情况下更新状态数据?
我有一个用户列表,我希望能够更新每个用户的详细信息(在模式中)并将其保持在状态(没有 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不需要提出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.