Promise-returning delay function

Sébastien Cevey seb.cevey at guardian.co.uk
Tue Sep 9 01:43:49 PDT 2014


On 9 Sep 2014 00:13, "Domenic Denicola" <domenic at domenicdenicola.com> wrote:

> (I also find the name `sleep` somewhat attractive, as a re-appropriation
from threaded contexts. `await sleep(1000)`, heh.)

Sleep has blocking semantics in all languages I've used it in (eg. C, Java,
Ruby, Bash, etc) so perhaps best avoid any confusion?

I've found `delay` very useful and natural in the context of
Rx.Observables, where it is a method to delay each element in a stream,
although that's a slightly different use case to what's proposed here.

What's the recommended way to add capabilities to Promises? Utility
functions, as suggested here? Promise subclassing/"casting"? Prototype
monkey patching (I guess not, but some will do that if there's no better
way...)?

Reminds me from the elegant/surprising obj::func() binding syntax Domenic
showed the other day in a presentation, too.

-- 

------------------------------
Visit theguardian.com. On your mobile and tablet, download the Guardian 
iPhone and Android apps theguardian.com/guardianapp and our tablet editions 
theguardian.com/editions.  Save up to 57% by subscribing to the Guardian 
and Observer - choose the papers you want and get full digital access. 
 Visit subscribe.theguardian.com

This e-mail and all attachments are confidential and may also be 
privileged. If you are not the named recipient, please notify the sender 
and delete the e-mail and all attachments immediately. Do not disclose the 
contents to another person. You may not use the information for any 
purpose, or store, or copy, it in any way.  Guardian News & Media Limited 
is not liable for any computer viruses or other material transmitted with 
or as part of this e-mail. You should employ virus checking software.
 
Guardian News & Media Limited is a member of Guardian Media Group plc. Registered 
Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP.  Registered 
in England Number 908396


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140909/83e90ea7/attachment.html>


More information about the es-discuss mailing list