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
0
votes
2 answers

how to resolve values in nodejs promises

I am new to promises Q node module. How to resolve values for promise object. Here is my example: function fs_readFile (file, encoding) { var deferred = Q.defer() fs.readFile(file, encoding, function (err, data) { if (err) …
sridhar
  • 861
  • 3
  • 10
  • 14
0
votes
1 answer

Using .always().error() syntax for Angular $q promises

I'm implementing just a thin wrapper around $http for our REST API, and I'm wanting it to return a promise in the same way as $http does (after I massage the data). Here's my service: Services.service('Item', ['$http', '$q', function($http, $q){ …
Josh Hunt
  • 14,225
  • 26
  • 79
  • 98
0
votes
1 answer

Unable to depend on Q via requirejs under Karma

In my project ChuckJS (be aware that it's GPL licensed) I'm running into this issue when trying to depend on Q via RequireJS, when running the project's Karma tests. What happens is that RequireJS throws this exception: Uncaught Error: Mismatched…
aknuds1
  • 65,625
  • 67
  • 195
  • 317
0
votes
2 answers

Promise - wrapping error during deferred.reject

I'm trying to create a deferred wrapper using q.js such that I can wrap errors (strings) in a custom error class before they're passed back by the promise in then() or fail(). This is what I'm doing at the moment: var getDeferred = function() { …
bluepnume
  • 16,460
  • 8
  • 38
  • 48
0
votes
1 answer

AngularJS $q.all timeout

I'm using AngularJS's $q function to group together several promises. However, I also want to set a timeout to cancel this promise and do something else if there isn't any response for any of these promises after a certain time. Is this…
Wei Hao
  • 2,756
  • 9
  • 27
  • 40
0
votes
1 answer

Why does Q's thenResolve method return undefined?

Why isn't thenResolve working as I expect? I have a method in a javascript module: function addVisit(companyId) { var newVisit; return getInventoryItems() .then(function(data) { newVisit = createVisit(companyId, data); …
Jamie Ide
  • 48,427
  • 16
  • 81
  • 117
0
votes
0 answers

Why can't I resolve a factory-provided deferred in a directive?

I'm trying to create a controller which waits for a promise who's deferred is resolved in a directive. But all I get is a silent failure, preventing both my controller and directive from executing or doing…
zakdances
  • 22,285
  • 32
  • 102
  • 173
0
votes
1 answer

Parallel calls and wait condition in NodeJS with Q or Async

I'm trying to retrieve products basis by categories, I'd like to parallel the process, first I'm not able to figure out how to write wait condition or ideal a call back method to let parent function know that all products have been retrieved from…
Nilay Parikh
  • 328
  • 3
  • 14
0
votes
2 answers

Handling an array of promises

I have a function which uploads a file to a server and returns a promise. I'd like to check when each promise finishes and display a log of "Successfully deployed filename..". I don't care about the order of the promises, But Q.all() doesn't help me…
shayy
  • 1,272
  • 2
  • 16
  • 26
0
votes
1 answer

Using Q - how to call an object's async function that updates object properties

I’m using Q promises with NodeJS and my code is not working as expected. I have an array of type ObjA. Each ObjA has a property, objB, of type ObjB. ObjB has an async method called extract that does an async task and sets / updates objB properties.…
0
votes
1 answer

Promises : Q.allSettled not waiting

I have a problem with a script in nodejs, using the Q library for promises. The script is supposed to: load a text from a text file, split sentences / words, count all the raw word occurrences, lemmatize the words using an external database…
glmxndr
  • 45,516
  • 29
  • 93
  • 118
0
votes
2 answers

Using Q to create an async user input sequence

I am toying with Q and promptly and I am trying to ask, in a sequence, the user to input some stuff. For example : What is your name? Bob What is your age? 40 Hello Bob (40)! (yes! it's a simple "Hello world!" program.) And here is the code I am…
Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
0
votes
1 answer

Breeze 1.4.2 Nuget External packages cannot depend on packages that target projects

When installing Breeze.WebApi 1.4.2 in a fresh project I am getting this error: PM> Install-Package Breeze.WebApi Attempting to resolve dependency 'Breeze.Client (≥ 1.4.2)'. Attempting to resolve dependency 'Q'. Install-Package : **External packages…
0
votes
1 answer

Issue with changing Q library version from 0.9.6 to 0.9.7

I was working with q library for a short period of time, and had success with processing data that I get from ajax in sequential manner. By sequential processing of data I mean that after each of ajax call, I do a set of .then( function(){} ) and…
Plyto
  • 741
  • 1
  • 9
  • 18
0
votes
2 answers

Q Promise chain and NodeJS callbacks

I think this is a really stupid question but I'm having a hard time wrapping my head around promises. I'm using Q (for nodejs) to sync up a couple of async functions. This works like a charm. var first = function () { var d =…
jansmolders86
  • 5,449
  • 8
  • 37
  • 51