Open Bug 1514315 Opened 7 years ago Updated 3 years ago

Consider adding a dom::Promise => MozPromise adapter class

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: nika, Unassigned)

References

Details

Currently, if we have a MozPromise or dom::Promise, it's tricky to get the other type of promise. It would be nice to provide a helper class which does this adapting for you, rather than having to do it manually.
Priority: -- → P3
MozPromise and Promise are very different beasts, but I agree it would be nice to be able to have some helper thingie to adapt from one to another. And would be nice to have simpler ways to use Promise in C++. It is still a bit JS-y. One issue is that MozPromises are about handling asynchronous chains in a certain way (or that is how I see them), but Promises aren't about asynchronousness (because they use microtasks). We need to be careful to not make long non-asynchronous *Promise chains in browser code - it is already a rather bad issue in the web pages to use too long Promise chains, which cause jank. So whatever we add need to be clear on that the conversion changes scheduling to something very different. (microtasks were designed for MutationObserver to be able to coalesce several mutations to one, still effectively synchronous, notification. It was basically a performance optimization for an API which had to be somewhat synchronous. I can't recall all the reasoning why Promises also use microtasks.)
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.