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 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 want to implement a dynamic loading of a static resource in AngularJS using Promises. The problem: I have couple components on page which might (or not, depends which are displayed, thus dynamic) need to get a static resource from the server. Onc...
I’m working on an Angular 6 application and I’ve been told the following is an anti-pattern:  await someFunction().then(result => {     console.log(result); });   I realize that it is pointless to await a promise chain. If someFunction() ret...
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 am checking out the "Promises/A+" Specification, but could not understand the following things:  On Section 1. Terminology,  1.1. "promise” is an object or function with a then method whose behavior conforms to this specification....
I am having a hard time running promises sequentially.  var getDelayedString = function(string) {     var deferred = Q.defer();      setTimeout(function() {         document.write(string+" ");         deferred.resolve();     }, 500);      r...
I'm trying to create a constructor for a blogging platform and it has many async operations going on inside. These range from grabbing the posts from directories, parsing them, sending them through template engines, etc.  So my question is, wou...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.