2 ms·
I've been using promises for my work lately, and I really like them. This doesn't have it, but one construct I use is the `when` function. It's useful for situa
by pfraze 14y ago
I've been using promises for my work lately, and I really like them. This doesn't have it, but one construct I use is the `when` function. It's useful for situations that may return non-promise values, and works like this:
Promise.when(func(), function(val) {
alert(val);
});
So if `func` returns a normal value, the cb runs immediately. If it returns a promise, the cb runs on fulfillment.