Multiple chained deferred functions using q in AngularJS stop returning data

Excerpt taken from the official doc on $q: then(successCallback, errorCallback) – regardless of when the promise was or will be resolved or rejected calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument the result or rejection reason. This method returns … Read more

How to actually use Q promise in node.js?

promiseMeSomething() is going to return a Q promise object, which will have then function in it, which is defined, like this Promise.prototype.then = function (fulfilled, rejected, progressed) { The simplest way to create a Promise object would be to use the Q function constructor, like this new Q(value) will create a new promise object. You … Read more

What happens if i reject / resolve multiple times in Kriskowal’s q?

Since promises can only resolve once (to either fulfilled or rejected), the first resolution wins and any further calls will be ignored. From the docs: In all cases where a promise is resolved (i.e. either fulfilled or rejected), the resolution is permanent and cannot be reset. Attempting to call resolve, reject, or notify if promise … Read more

How to chain a variable number of promises in Q, in order?

There’s a nice clean way to to this with [].reduce. var chain = itemsToProcess.reduce(function (previous, item) { return previous.then(function (previousValue) { // do what you want with previous value // return your async operation return Q.delay(100); }) }, Q.resolve(/* set the first “previousValue” here */)); chain.then(function (lastResult) { // … }); reduce iterates through the … Read more

Define empty Bluebird promise like in Q

Florian provided a good answer For the sake of your original question, there are several ways to start a chain with Bluebird. One of the simplest is calling Promise.resolve() on nothing: var queue = Promise.resolve(); //resolve a promise with nothing or cast a value or Promise.try(function(…){ return …//chain here }); So you can do: var … Read more

How to properly abort a node.js promise chain using Q?

This is a case where you will need to branch, which does mean either nesting or creating a subroutine. function doTask(task, callback) { return Q.ncall(task.step1, task) .then(function(result1) { if (result1) return result1; return Q.ncall(task.step2, task) .then(function(result2) { return Q.ncall(task.step3, task); }) }) .nodeify(callback) } Or function doTask(task, callback) { return Q.ncall(task.step1, task) .then(function(result1) { if … Read more

Problems inherent to jQuery $.Deferred (jQuery 1.x/2.x)

Update: jQuery 3.0 has fixed the problems outlined below. It is truly Promises/A+ compliant. Yes, jQuery promises have serious and inherent problems. That said, since the article was written jQuery made significant efforts to be more Promises/Aplus complaint and they now have a .then method that chains. So even in jQuery returnsPromise().then(a).then(b) for promise returning … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)