如何根据正在进行的操作来审问?

发布于 2025-02-13 12:41:24 字数 388 浏览 1 评论 0原文

我有一种可以自动保存的角形式。保存功能有多个部分,可能需要一些部分。储蓄是根据更改表单值触发的。

显然,我可以使用可观察到的表单值更改表单,但是如何防止多次保存调用一次呢?

我想要的是:

  1. 用户更改一些输入字段
  2. 自动保存是触发的,并
  3. 在保存完成之前采用2s,用户更改更多字段
  4. 代码等待当前保存操作完成,然后启动另一个保存呼叫 - 只有一个,只有一个,即使有几个字段的变化在审核限制之外。

我一直在研究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:

  1. User changes some input fields
  2. Auto-save is triggered and takes 2s
  3. Before that save is completed, user changes more fields
  4. 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 技术交流群。

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

发布评论

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

评论(1

北渚 2025-02-20 12:41:24

You can have a look on exhaustMap https://rxjs.dev/api/operators/exhaustMap.

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