Questions tagged [q]

The Q.js JavaScript promise library. Q catches errors and uses a `then` technique to handle JavaScript callbacks and exceptions. Do *not* use for Angular's $q, use [angular-promise] instead! Also do *not* use for kx System's kdb+/q, use [kdb] or [q-lang] instead! Lastly, this tag should not be used for questions regarding Android 10 - use the [android-10.0] tag instead!

A JavaScript library for the browser and Node.js for making and composing asynchronous promises. Q catches errors and uses a then technique to handle JavaScript callbacks and exceptions.

1381 questions
36
votes
4 answers

Define empty Bluebird promise like in Q

With Q I can define a new promise with: var queue = q(); But with Bluebird if I do: var queue = new Promise(); I get: TypeError: the promise constructor requires a resolver function How can I get the same result that I had with Q? This is a…
Fez Vrasta
  • 14,110
  • 21
  • 98
  • 160
36
votes
3 answers

How to properly abort a node.js promise chain using Q?

I'm using the Q module for Node.js in attempts to avoid the "pyramid of doom" in scenarios where I have many steps. For example: function doTask(task, callback) { Q.ncall(task.step1, task) .then(function(result1){ return…
Zane Claes
  • 14,732
  • 15
  • 74
  • 131
35
votes
3 answers

How to wait for a promise to be resolved?

I'm dealing with a NodeJs framework that requires a certain function to be synchronous, but I need to retrieve a value that can only be accessed asynchronously. In a perfect world, I would be able to return a promise, but I can't. As a…
sinθ
  • 11,093
  • 25
  • 85
  • 121
34
votes
4 answers

How to chain a variable number of promises in Q, in order?

I have seen Chaining an arbitrary number of promises in Q ; my question is different. How can I make a variable number of calls, each of which returns asynchronously, in order? The scenario is a set of HTTP requests, the number and type of which…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
34
votes
3 answers

Use jQuery or Q.Js for promises

I'm looking into BreezeJs and there samples are using Q.js for promises to handle asynchronous calls. John Papa is also using Q. JQuery has promises as well. What are the differences between the two?
AlignedDev
  • 8,102
  • 9
  • 56
  • 91
33
votes
1 answer

How to actually use Q promise in node.js?

This might be a noob question, but I'm new to promises and trying to figure out how to use Q in node.js. I see the tutorial begins with a promiseMeSomething() .then(function (value) {}, function (reason) {}); but I fail to grasp where exactly…
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
33
votes
2 answers

What happens if i reject / resolve multiple times in Kriskowal's q?

I'm studying the promises pattern and using kriskowal's q for node.js, having this snippet: var deferred = Q.defer(); try { messageData = JSON.parse(message); } catch (e) { global.logger.warn('Error parsing JSON message.'); …
Luca Vitucci
  • 3,674
  • 4
  • 36
  • 60
32
votes
1 answer

Multiple chained deferred functions using q in AngularJS stop returning data

I am trying to chain together multiple deferred function calls such that the next call gets the results of the previous deferred.resolve. When I chain together more than 2 of these calls, the data stops being returned. Here is the basic code inside…
BoxerBucks
  • 3,124
  • 2
  • 21
  • 26
32
votes
1 answer

Using promises - Logging stack trace in fail handler

I am rather new to nodejs so I will explain in a bit more detail what I am trying to do. I have a webserver. If a request fails I want to log the stack trace of that exception, but deliver a error page and not crash the server. As an example, the…
dave
  • 4,024
  • 2
  • 18
  • 34
29
votes
4 answers

How to configure additional classpath in SpringBoot?

I want to make a standalone web application. I have some problems with SpringBoot. My application is one jar file from SpringBoot. But my application was usually needed jdbc driver jar. I want to exclude the jdbc driver jar for my application and…
fightingmamoru
  • 416
  • 1
  • 6
  • 11
28
votes
3 answers

Node.js Asynchronous Library Comparison - Q vs Async

I have used kriskowal's Q library for a project (web scraper / human-activity simulator) and have become acquainted with promises, returning them and resolving/rejecting them, and the library's basic asynchronous control flow methods and…
Jackson
  • 9,188
  • 6
  • 52
  • 77
27
votes
4 answers

Proper way to skip a then function in Q Promises

In my code, based on a specific condition, I would like to skip to the done function, irrespective of all the then functions. The original version of this question is in the edits. The following is the actual problem I am dealing with. Sorry for the…
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
26
votes
6 answers

Promises: Repeat operation until it succeeds?

I want to perform an operation repeatedly, with an increasing timeout between each operation, until it succeeds or a certain amount of time elapses. How do I structure this with promises in Q?
Jay Bienvenu
  • 3,069
  • 5
  • 33
  • 44
22
votes
2 answers

How to make Ajax request through NodeJS to an endpoint

I am using NodeJS. One of my function (lets call it funcOne) receives some input which I pass to another function (lets call it funcTwo) which produces some output. Before I pass the input to funcTwo I need to make an Ajax call to an endpoint…
SharpCoder
  • 18,279
  • 43
  • 153
  • 249
22
votes
2 answers

When to reject/resolve a promise

I am thinking about when exactly I need to reject a promise. I found a couple of questions regarding this topic, but could not find a proper answer. When should I reject a promise? This…
Christopher Will
  • 2,991
  • 3
  • 29
  • 46
1
2
3
92 93