如何根据正在进行的操作来审问?
我有一种可以自动保存的角形式。保存功能有多个部分,可能需要一些部分。储蓄是根据更改表单值触发的。
显然,我可以使用可观察到的表单值更改表单,但是如何防止多次保存调用一次呢?
我想要的是:
- 用户更改一些输入字段
- 自动保存是触发的,并
- 在保存完成之前采用2s,用户更改更多字段
- 代码等待当前保存操作完成,然后启动另一个保存呼叫 - 只有一个,只有一个,即使有几个字段的变化在审核限制之外。
我一直在研究RXJS文档,但是很复杂,我找不到任何适合用例的东西。我了解我可以将操作员结合在一起,但是我不确定要组合哪些和/或如何组合。有一个Debounce()操作员需要另一个可观察到的操作员,但这似乎是可以观察到的,可以确定签出的时间。
I have an Angular form that will auto-save. The save functionality has several parts and might take a bit. Saving is triggered based on form values changing.
I obviously can use an Observable to debounce the form values changing, but how do I prevent multiple save calls from happening at once?
What I want:
- User changes some input fields
- Auto-save is triggered and takes 2s
- Before that save is completed, user changes more fields
- Code waits for the current save operation to complete, and then fires off another save call -- and only one, even if there were several fields changed outside of the debounce limit.
I've been digging through RxJS documentation, but it's complicated and I'm not finding anything that fits my use case. I understand I can combine operators, but I am unsure which ones to combine and/or how. There is a debounce() operator that takes another Observable, but this seems to just be an Observable to determine the time to debounce.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看
dyailmap
https://rxjs.dev/api/操作员/排气模式。You can have a look on
exhaustMap
https://rxjs.dev/api/operators/exhaustMap.