angular / zone.js

Implements Zones for JavaScript
https://github.com/angular/angular/tree/master/packages/zone.js/
MIT License
3.25k stars 408 forks source link

Patch decodeAudioData #1165

Closed maximedupre closed 5 years ago

maximedupre commented 5 years ago

Using the promise version of decodeAudioData returns a zone aware promise, but since this method has not been patched, the operation is not included in the list of microtasks.

context.decodeAudioData(ab).then(this.audioDataDecoded.bind(this))
this.ngZone.hasPendingMicrotasks // returns false
Promise.resolve(null).then(() => {});
this.ngZone.hasPendingMicrotasks // returns true

Using zone v0.8.26

JiaLiPassion commented 5 years ago

I will try it later, thanks!

maximedupre commented 5 years ago

Maybe that the .then is added as a micro task once the decoding is done?

JiaLiPassion commented 5 years ago

@maximedupre, yes, you are right, when decodeAudioData is finished, hasPendingMicrotasks will be true.

maximedupre commented 5 years ago

Shouldn't there be a pending microtrask as soon as the .then is called?

JiaLiPassion commented 5 years ago

No, this is how promise worked, microtask only scheduled when promise is resolved or rejected.