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...
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)...
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...
I have to make a sequence of fetch() Promise: I have only 1 url at a time, this means only 1 fetch() promise. Every time I receive a json,this one contains an url for another json, so I have to make another fetch() promise.  I'm able to work wi...
Using the native (ES6) Promise. Should I reject with an Error:  Promise.reject(new Error('Something went wrong'));   Or should I just reject with a string:  Promise.reject('Something went wrong');   And what is the difference in bro...
I would like to catch all unhandled exceptions/rejections that take place within a javascript Promise. Is there a good method for catching them without adding a .catch(..) on each end of the Promise chain? (in case of forgetting to add this, the er...
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...
I'd like to explain to myself the execution order of the following snippet that uses javascript promises.  Promise.resolve('A')   .then(function(a){console.log(2, a); return 'B';})   .then(function(a){      Promise.resolve('...
This question already has an answer here:...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.