Promise-returning delay function

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Oct 28 15:38:12 PDT 2014


try to put a cancel in your same code:

```js
function tryToAscend() {
return Door.close().then(function() { return raiseLift(); },
function(e) { return Door.open().delay(10*1000).then(tryToAscend); });
};
```

because when the door opens somebody cancel the floor and wants to descend
instead.

Then implement the case when actually the call was simply canceled and
nobody has to go anywhere ... all while delay keeps saying to each floor
that after 10 seconds doors should close anyway.

Now try to pass this glorious flow around per each panel in each floor that
should behave accordingly.

Can you do this via Promises? 'cause I'm pretty sure that code won't look
any better than an event based one, but I can be wrong.

Regards




On Tue, Oct 28, 2014 at 10:30 PM, C. Scott Ananian <ecmascript at cscott.net>
wrote:

> Again, I don't see how this requires some new sort of control flow.
>  --scott
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141028/c9354580/attachment-0001.html>


More information about the es-discuss mailing list