4 ms·
It's a method with a signature like this: promise.then(callback) so: var p = doSomethingAsync(); p.then(function () { alert("hello"); })
by kevingadd 15y ago
It's a method with a signature like this:
promise.then(callback)
so:
var p = doSomethingAsync();
p.then(function () { alert("hello"); })
- rwolf 15y agoI saw all of those extra spaces around "then" in the article and assumed the worst. Thanks for clearing that up for me!
- nxn 15y agoI'm assuming they only chose to use this pattern for the purpose of keeping function/method signatures as uniform across the languages as possible? I can't see another advantage to this in JS. Seems like all it's doing is wrapping the call to the actual async operation within the 'then' function, and then probably using the callback as the last argument or storing it somewhere where it will be accessible to the async operation right before it returns.