然后以同步方法的问题发行
我正在听第三方控制的事件,从一个阶段移到另一个阶段(过程流)。 在该方法中,您可以阻止进度,从而阻止用户移至下一阶段。 但是,如果我使用异步方法订阅此事件,则该阻止方法没有任何效果(逻辑上是合乎逻辑的),
但我需要调用仅支持异步调用的API(获取数据)。 这是要检查用户是否能够进步。 因此,我需要能够在异步方法调用过程中让我的方法“ pauze”的主要执行,或者能够以同步方式调用它。
我尝试了一个布尔值,该布尔被设置为false在这样的诺言的条件下:
let runningAsync = true
AsyncMethod.then(function() {runningAsync = false})
while (runningAsync)
{
}
这确实阻止了我对同步方法的执行,但是在异步方法中,我呼吁使用异步API。由于某种原因,它只是挂在那个呼叫上,就好像无法完成(可能是由于某个地方的循环)。
一直在为此打破我的头脑,但找不到适当的解决方案。 任何建议都将不胜感激...
问: 斯文
I'm listening to an event from a 3th party control, pre moving from one stage to another (process flow).
Within that method you are able to block the progress, preventing the user to move to the next stage.
However, if I subscribe to this event with an async method, that blocking method does not have any effect (which is logical)
Unfortunately I need to call an api (fetching data) that only support async calls.
This is to check if the user is able to progress or not.
So I need to be able to either let the main execution of my method 'pauze' during the async method call or able to call it in a sync way.
I tried with a boolean that is set to false in the .then condition of the promise like this :
let runningAsync = true
AsyncMethod.then(function() {runningAsync = false})
while (runningAsync)
{
}
This does stop my execution on my sync method BUT within my AsyncMethod I have the call to that async API. And for some reason it just hangs on that call as if it's unable to complete (probably due to the while loop somewhere).
Been breaking my head on this but can't find a proper solution for this issue.
Any suggestion would be much appreciated ...
Regards,
Sven
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论