New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to MacrotaskExecutor
on JS
#1522
Switch to MacrotaskExecutor
on JS
#1522
Conversation
private[this] val executeRef: js.Dynamic = { | ||
if (js.typeOf(js.Dynamic.global.setImmediate) == "function") | ||
js.Dynamic.global.setImmediate | ||
else | ||
js.Dynamic.global.setTimeout | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MacrotaskExecutor
is basically an advanced version of this conditional. First it looks for setImmediate
(best performance). However, if that's not available, instead of giving up and falling back to setTimeout
(very bad performance), MacrotaskExecutor
attempts to implement a number of higher-performance polyfills instead.
Yes, according to scala-js/scala-js#4129 (comment):
|
I was thinking of doing window.postMessage, not sure if feasible |
I took the liberty of merging with the base branch, and doing some fixes in Note that in Monix I'd prefer to drop 3rd party dependencies in the core modules, however seeing this is an "official" Scala.js project, I guess it's all good. Thanks for the PR. Will merge as soon as the build passes. |
Yes, I read your blog post about the CE2/CE3 thing and 👍 The MacrotaskExecutor project should be very stable, ideally as stable as Scala.js itself. It's not part of Scala.js core largely due to their own policy/preference to avoid polyfills and non-standard APIs in core. |
Co-authored-by: Arman Bilge <armanbilge@gmail.com>
Closes #1519. Targeting series/3.x.
See https://github.com/scala-js/scala-js-macrotask-executor for more details.
Some notes:
StandardContext
this replaces actually did not suffer from the fairness problem that the default globalExecutionContext
in Scala.js does. However, it seems like it would suffer from serious performance issues when used in browsers. Is anyone aware of this?