You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executed, the above code prints out "Value: undefined" after a 5 second pause. I was expecting it to print out "Value: hello world" after a one second pause.
My expectation is that the deferred.wait() would be interrupted by the deferred.resolve() in the setTimeout handler. But instead deferred.wait() blocks the setTimeout countdown timer because it is also on the main event thread.
The following code illustrates the affect I was hoping to achieve.
There would be issues with this naive replacement for setTimeout, particularly the fact that the concept of 'this' is changed. Calling new Timeout like this would solve that problem:
So, I'm not particularly suggesting an enhancement or pointing out a defect. There may be very good reasons why setTimeout has to be run on the main event loop.
The inclusion of Promise.wait() is a very nice option when blocking is required, so I am glad to have it available, even if it requires some additional knowledge regarding its use.
The text was updated successfully, but these errors were encountered:
there is something fishy about our promise.wait(). it's built on the assumption that the promise is coming from another worker because only then can it ever resolve. but we actually suggest - but don't enforce - strict worker seperation.
I’m closing this issue because it has been inactive for a long time. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on for so long, then it seems no one has the time to implement this / there is no interest in it.
Please reopen if you still encounter this issue with the current master version or there is a need to address this issue.
I wasn't sure what to type for the subject as this isn't quite a bug or an enhancement request. It's just a behavior that could be changed perhaps.
When executed, the above code prints out "Value: undefined" after a 5 second pause. I was expecting it to print out "Value: hello world" after a one second pause.
My expectation is that the deferred.wait() would be interrupted by the deferred.resolve() in the setTimeout handler. But instead deferred.wait() blocks the setTimeout countdown timer because it is also on the main event thread.
The following code illustrates the affect I was hoping to achieve.
There would be issues with this naive replacement for setTimeout, particularly the fact that the concept of 'this' is changed. Calling new Timeout like this would solve that problem:
So, I'm not particularly suggesting an enhancement or pointing out a defect. There may be very good reasons why setTimeout has to be run on the main event loop.
The inclusion of Promise.wait() is a very nice option when blocking is required, so I am glad to have it available, even if it requires some additional knowledge regarding its use.
The text was updated successfully, but these errors were encountered: