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'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)...
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 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)...
I have a loop which calls a method that does stuff asynchronously. This loop can call the method many times. After this loop, I have another loop that needs to be executed only when all the asynchronous stuff is done. So this illustrates what I wan...
In this answer, a promise chain is built recursively.  Simplified slightly, we have :  function foo() {     function doo() {         // always return a promise         if (/* more to do */) {             return doSomethingAsync().then(doo);...
Given    function doStuff(n /* `n` is expected to be a positive number */) {   return new Promise(function(resolve, reject) {     setTimeout(function() {       resolve(n * 10)     }, Math.floor(Math.random() * 1000))   })   .then(function(result) {...
I've just finished reading the Promises/A+ specification and stumbled upon the terms microtask and macrotask: see http://promisesaplus.com/#notes  I've never heard of these terms before, and now I'm curious what the difference could be?...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.