I Have Many Causes To Hope

by GinoUpjohn344612998 posted Mar 14, 2023


Prev이전 문서

Next다음 문서


크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제

One of the things I've poured myself into this 12 months -- with a merry band of contributors together with Domenic Denicola, Anne van Kesteren, Jake Archibald, Mark Miller, crawler chassis Erik Arvidsson, and lots of others -- has been a design for Promises that DOM and JS can both adopt. There is a (very) lengthy historical past of Promises, Deferreds, and numerous different Promise-ish issues in JS which I won't bore you with here except to note that there are only a few client-side libraries which do not embrace such a factor and use it as a core idiom for coping with async behvaior (e.g., XHR).

Query, Dojo, Q, WinJS, Cujo, Closure, YUI, Ember (by way of RSVP), and all of the rest use this style of contract pervasively and have for years. The most important libraries are coalescing round that contract and so it appears time, finally, to make our largest and most necessary library -- DOM -- savvy to them too.


The recent historical past starts (arbitrarily) a couple of years ago and ends 2 weeks ago. API we've designed want not upset anyone's applecart.

The TC39 meeting was a key turning point: up till 2 weeks in the past, DOM had a model of this design underneath the title Future. I made the choice to not use the title Promise for that work because with out TC39's agreement on a design, the DOM variant may at some point discover itself each camping on a world identify and disagreeing with JS about semantics or naming of particular APIs. That kind of thing might have lead to the suspicion by DOM of us that TC39 was out of touch and slow, and by TC39 that DOM rushed in like fools into a space that's fairly clearly one thing the std lib ought to embody (even when it could not achieve this for multiple years due to publication and spec timing issues).

Guarantees, notably Web Crypto and Internet MIDI.

There has additionally been lively dialogue about different APIs that may profit from transferring to an ordinary mechanism for describing async operations. It seems, in each particular person case, like this shouldn't be such an enormous deal. The large purpose to spend months of my life on this problem, and to harass other very busy folks to do the same, is to me the core value of internet standards: after they're working effectively, they create a uniform surface area that describes a coherent platform.

We are the beneficiaries of this uniformity at the moment concerning events, and they're a significant piece of the design language which DOM API authors can reliably use to assist describe bits of their design. Promises, like Events, are yet another software within the box that DOM APIs authors can use, and due to sane constructors and the flexibility to subclass constructed into the design, it's doable for finish-person code to eventually put down the custom implementations of Promise-like things and merely depend on the platform to do what platforms should do: make low cost and straightforward what previously was common but expensive.