[英]Aurelia stop overload of http requests
I'm using Aurelia and have multiple promises calling my API. 我正在使用Aurelia,并且有多个Promise调用我的API。 If I continually click the button to fire the promises over and over and over again the back end will timeout.
如果我连续单击该按钮一次又一次地触发承诺,则后端将超时。 How can I stop/halt the promises I am firing and just get the newest one so as to not over work the API and cause a timeout?
我如何停止/停止我正在履行的承诺,而只是获得最新的承诺,以免API过度工作并导致超时?
This is not specific to aurelia, it happens with any asynchronous event implementation. 这不是aurelia特有的,它发生在任何异步事件实现中。
If you don't want this behaviour, it is up to you to prevent the user from submitting again until the AJAX request completes. 如果您不希望这种行为,您可以自行决定阻止用户在AJAX请求完成之前再次提交。 For example you could:
例如,您可以:
Note that giving user feedback is good UX anyway. 请注意,无论如何,给予用户反馈都是好的UX。 A network request might be delayed for a whole lot of reasons and it is a good idea to give some feedback to let him know that something is happening.
网络请求可能由于很多原因而被延迟,因此最好提供一些反馈以使他知道正在发生某些事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.