Tab Atkins Jr. (2014-02-06T00:44:55.000Z)
On Wed, Feb 5, 2014 at 3:51 PM, Brendan Eich <brendan at mozilla.com> wrote:
> Tab Atkins Jr. wrote:
>> But say you wanted to do something a bit more complicated.  For
>> example, if the cache hits, but the result is a Promise, you might
>> want to show a throbber until the Promise resolves.  Under the old
>> consensus, you could do this pretty easily - just do
>> "cache.get().chain(...)" and then operate on the result.  Under the
>> new, you can't, because the cache promise won't resolve until after
>> the response promise resolves.  We can't say "just hand-box", because
>> it breaks the easy pattern above when you*don't*  want to do anything
>>
>> complicated - you have to .then() it and unbox there.
>
> Yeah, that would suck for the pretty one-liner. But is it really that much
> more? Write it out and let's see A vs. B.

e.respondWith(cache.get('foo').then(x=>x[0]))

...which doesn't look like much until you realize you have to repeat
the invocation on every single cache retrieval.  (And remember to box
with [] on every cache set, or else the retrieval will error out.)

~TJ
domenic at domenicdenicola.com (2014-02-10T22:48:15.574Z)
On Wed, Feb 5, 2014 at 3:51 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Yeah, that would suck for the pretty one-liner. But is it really that much
> more? Write it out and let's see A vs. B.

```js
e.respondWith(cache.get('foo').then(x=>x[0]))
```

...which doesn't look like much until you realize you have to repeat
the invocation on every single cache retrieval.  (And remember to box
with [] on every cache set, or else the retrieval will error out.)