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...
Let's say I have a set of promises that are making network requests, of which one will fail:  // http://does-not-exist will throw a TypeError var arr = [ fetch('index.html'), fetch('http://does-not-exist') ]  Promise.all(arr)...
Consider the following code that reads an array of files in a serial/sequential manner. readFiles returns a promise, which is resolved only once all files have been read in sequence.  var readFile = function(file) {   ... // Returns a promise. };...
I am have a problem understanding why rejections are not passed on through a promise chain and I am hoping someone will be able to help me understand why. To me, attaching functionality to a chain of promises implies an intent that I am depending o...
I like the flatness of the new Async/Await feature available in Typescript, etc. However, I'm not sure I like the fact that I have to declare the variable I'm awaiting on the outside of a try...catch block in order to use it later. Like so:...
I have an array of promise objects that must be resolved in the same sequence in which they are listed in the array, i.e. we cannot attempt resolving an element till the previous one has been resolved (as method Promise.all([...]) does).  And if on...
Let's say I have a set of Promises that are making network requests, of which one will fail:  // http://does-not-exist will throw a TypeError var arr = [ fetch('index.html'), fetch('http://does-not-exist') ]  Promise.all(arr)...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.