asap icon indicating copy to clipboard operation
asap copied to clipboard

Consider using Promise.prototype.then

Open RangerMauve opened this issue 10 years ago • 4 comments

There's a blog post about how using Promise.then is supposedly even faster than .nextTick.

Given that we have stuff like io.js with Promise support and a lot of browser supporting it to, do you think it'd make sense to conditionally use this feature if it exists?

RangerMauve avatar Feb 23 '15 23:02 RangerMauve

We need to be a little careful with polyfills for Promise that use this library internally.

ForbesLindesay avatar Feb 24 '15 00:02 ForbesLindesay

Yeah, there could be something like this code to check that the Promise implementation is indeed native:

if(typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1){
    // it's native
}

Shamelessly grabbed from Benjamin Gruenbaum

RangerMauve avatar Feb 24 '15 02:02 RangerMauve

FYI, there seems to be a bug in Firefox microtask scheduling using a resolved Promise, see https://bugzilla.mozilla.org/show_bug.cgi?id=1162013

vicb avatar May 06 '15 13:05 vicb

On Chrome, Promise does not seem be faster than MutationObserver.

RubenVerborgh avatar Aug 15 '16 23:08 RubenVerborgh