setTimeout & nextTick were in source-definition order. No matter how many promises I added, they always got executed first. handy!
All of them fire immediately after the animation frame has fired:
FRAME 5887.924999988172 (16.919000016059726) | |
bpm.js:26 Promise: 0.6000000284984708 | |
bpm.js:26 Promise2: 0.7890000124461949 | |
bpm.js:26 Promise3: 1.0040000197477639 | |
bpm.js:26 Promise4: 1.201000006403774 | |
bpm.js:26 Promise5: 1.4269999810494483 | |
bpm.js:26 Promise6: 1.5709999715909362 | |
bpm.js:26 setTimeout: 2.2609999869018793 | |
bpm.js:26 nextTick: 2.470000006724149 |
FRAME 37132.854074 (17.43204200000764) | |
Promise: 0.5772119999965071 | |
Promise2: 0.7072809999954188" | |
Promise3: 0.7976219999982277" | |
Promise4: 0.9323459999941406" | |
Promise5: 1.0101159999976517" | |
Promise6: 1.0780389999999898" | |
setTimeout: 6.087636999996903 | |
nextTick: 6.3192589999962365 |
animate() { | |
let now = window.performance.now() | |
console.debug(`FRAME ${now} (${now - this.last})`) | |
this.last = now | |
let timeCallback = name => () => { | |
let next = window.performance.now() | |
console.debug(` ${name}: ${next - this.last}`) | |
} | |
setTimeout(timeCallback("setTimeout"), 0) | |
nextTick(timeCallback("nextTick")) | |
Promise.resolve() | |
.then(timeCallback("Promise")) | |
.then(timeCallback("Promise2")) | |
.then(timeCallback("Promise3")) | |
.then(timeCallback("Promise4")) | |
.then(timeCallback("Promise5")) | |
.then(timeCallback("Promise6")) |