- From: Ian Hickson <ian@hixie.ch>
- Date: Wed, 17 Jul 2013 21:08:35 +0000 (UTC)
- To: Justin Novosad <junov@google.com>, Anne van Kesteren <annevk@annevk.nl>, "Tab Atkins Jr." <jackalmage@gmail.com>, Rick Waldron <waldron.rick@gmail.com>
- Cc: WHAT Working Group <whatwg@whatwg.org>
On Wed, 19 Jun 2013, Justin Novosad wrote: > > I was about to launch the implementation of window.createImageBitmap in > Blink, and I received feedback on the blink-dev mailing list that the > "Promise" API is the wave of the future for asynchronous JS, and that > the new createImageBitmap method should use Promises. > > Current spec: > http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#images > > The proposal is to change the ImageBitmapFactories IDL to something like > this: > > [NoInterfaceObject] > interface ImageBitmapFactories { > Promise createImageBitmap(ImageBitmapSource image, optional long sx, long > sy, long sw, long sh); > }; > > The value of the promise would resolve to an ImageBitmap object. Done. On Thu, 20 Jun 2013, Anne van Kesteren wrote: > > I think something like > > interface ImageBitmap { > static Promise create(ImageBitmapSource image, optional long sx, > long sy, long sw, long sh); > }; > > would be much nicer. Why? On Thu, 20 Jun 2013, Justin Novosad wrote: > > I agree it would be nicer, but it seems less consistent with other > existing APIs. Indeed. On Thu, 20 Jun 2013, Tab Atkins Jr. wrote: > > There's really no consistency here anyway, and the "Interface.create()" > idiom is pretty easy and nice. There are basically two styles: - constructors (new Date(), new Function(), etc) - factory methods on the "parent" object (document.createElement(), implementation.createDocument(), context.createLinearGradient(), etc) I don't think we have anything that uses the interface.create() pattern. URL.createObjectURL() is the closest, and it's not a factory. The constructor pattern is obviously better where possible, but in this case it's not, since it has to be async (hence Promises). -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 17 July 2013 21:09:08 UTC