I was writing code that does something that looks like:  function getStuffDone(param) {           | function getStuffDone(param) {     var d = Q.defer(); /* or $q.defer */ |     return new Promise(function(resolve, reject) {     // or = new $.Defer...
I want to work with promises but I have a callback API in a format like:  1. DOM load or other one time event:  window.onload; // set to callback ... window.onload = function() {  };   2. Plain callback:  function request(onChangeHandler) {     ......
I have restructured my code to promises, and built a wonderful long flat promise chain, consisting of multiple .then() callbacks. In the end I want to return some composite value, and need to access multiple intermediate promise results. However th...
I've been developing JavaScript for a few years and I don't understand the fuss about promises at all.  It seems like all I do is change:  api(function(result){     api2(function(result2){         api3(function(result3){              // do...
How to correctly construct a loop to make sure the following promise call and the chained logger.log(res) runs synchronously through iteration? (bluebird)  db.getUser(email).then(function(res) { logger.log(res); }); // this is a promise   I tried t...
I'm reading this tutorial about Bookshelf. Bookshelf uses Bluebird promises. There's quite a few examples that look something like this:  var getEvents = function(participantId) {     return new models.Participant()     .query({where: {id:...
I'd like to use the MongoDB native JS driver with bluebird promises. How can I use Promise.promisifyAll() on this library?...
It seems generally that creating deferred objects is now commonly discouraged in favor of using the ES6-style Promise constructor. Does there exist a situation where it would be necessary (or just better somehow) to use a deferred?  For example, on...
As a node programmer. I'm used to use "nodebacks" for handling errors in my code:  myFn(param, function(err, data) {     if (err){         //error handling logic      }      else {         // business logic     } });   When writing that...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.