W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

Re: Resolving Futures w/multiple values

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Wed, 24 Apr 2013 17:01:26 +0200
To: Dave Longley <dlongley@digitalbazaar.com>
Cc: www-dom@w3.org, Anne van Kestern <annevk@annevk.nl>, slightlyoff@chromium.org
Message-ID: <qjsfn8ps5jk1bskge0cpq03b3scdgref5p@hive.bjoern.hoehrmann.de>
* Dave Longley wrote:
>In order to convert this continuation-passing style API to a Future, a 
>wrapper creates a new function that wraps the async operation and passes 
>a callback that will call reject() if a non-null 'err' parameter is 
>defined and resolve() with an array containing both 'bar' and 'baz' 
>otherwise. The code to use such a wrapper and its resulting Future might 
>look like:
>
>futureFoo = wrap(foo);
>futureFoo(param1, param2).done(function(value) {/*value is [bar, 
>baz]*/}, function(err) {})
>
>This will be a bit odd for anyone used to using the library, but it is 
>at least usable, unless 'bar' can be either an array or an object and 
>'baz' is optional. Then the results are indeterminate.

I don't see the problem here. `value` would never be `bar`, it would be
`[bar, ...]` because you always box the value to avoid this problem.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Wednesday, 24 April 2013 15:01:58 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC