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
1 answer

Q.ninvoke with node-soap library evaluating function call too early

I am using node-soap to integrate with an external soap-based API. With this library, a client object is created at runtime based on the WSDL. Therefore, the soap client object is not valid at design time. This is a problem trying to use the Q…
bschulz
  • 191
  • 2
  • 12
0
votes
1 answer

Promise chain with each

I have this code: GamesStatsService.query({ level: 1 }).$promise.then(function(consoles) { $scope.consoles = consoles; _.each(consoles, function(c) { GamesStatsService.query({ consoleName: c.id, level: 2…
0
votes
2 answers

Q Promises - Run all promises in group 1, then group 2, then group N

I have N number of groups of promises and I simply want to run all promises in group 1, and then when all successful, all the promises in group 2, etc up to group N. My promises are all wrapping traditional async calls so I'm using Q's defer…
nogridbag
  • 3,521
  • 4
  • 38
  • 51
0
votes
1 answer

Is there a more convenient way to handle a Q promise result when saving a mongoose model?

We have a recurring pattern in our application when persisting an instance of a mongoose model to the data, which looks like this: var newClient = new Client.model( data ); Q.ninvoke( newClient, "save" ) .then( function( newEntity, numberAffected…
Oliver Salzburg
  • 21,652
  • 20
  • 93
  • 138
0
votes
1 answer

How to abort a failing Q promise in Node.JS

Let's say I'm building a registration flow, and I have something that looks like this: Q.nfcall(validateNewRegCallback, email, password) .fail(function(err){ console.log("bad email/pass: " + err); return null; }) …
Newtang
  • 6,414
  • 10
  • 49
  • 70
0
votes
1 answer

AngularJS $q.all() results are null

I'm trying to implement a $q.all to run some functions and then return all the outputs into a function attached to the .then at the end. At the moment the promises look like they're calling in the correct order and the $all .then is occurring at the…
Neil Hill
  • 61
  • 1
  • 1
  • 7
0
votes
1 answer

Recursion using promise api

Please find the code here http://plnkr.co/edit/zwCYGQaxyGyr7kL6fLKh?p=preview I am trying to do recursion with an async function which uses promise. I wanted to happen it serially (so no $q.all), and want to wait till all the nodes are processed…
bsr
  • 57,282
  • 86
  • 216
  • 316
0
votes
1 answer

promise and collection of loops

Help me understand what is wrong with my code please. So what I have to do is to call an async call to get a count. I have made that into a promise. function getCount(client) { var xml = "
reza
  • 5,972
  • 15
  • 84
  • 126
0
votes
1 answer

How to use $q to get a promise from a $broastcast in angularJS

Right now my controller code looks like this: $scope.spAPI.load(id).then(function(result){ var deferred = $q.defer(); if(result !== undefined){ deferred.resolve($rootScope.$broadcast("onSpLoaded", result)); } return…
Alex C
  • 1,334
  • 2
  • 18
  • 41
0
votes
1 answer

Q promises - Parse result vs nbind

Im working with node.js, Mongoose and the Q library for promises (https://github.com/kriskowal/q/wiki/API-Reference) I was wondering what's the difference between: var Kitty = mongoose.model("Kitty"); var findKitties = Q.nbind(Kitty.find,…
davibq
  • 1,089
  • 11
  • 31
0
votes
2 answers

Breezejs: [Q] Unhandled rejection reasons (should be empty)

I've seen other questions that ask this, and I don't feel my issue is a duplicate of those. Breezejs [Q] Unhandled rejection reasons (should be empty) Unhandled rejection reasons (should be empty) Okay so I've been following up on breezejs;…
sksallaj
  • 3,872
  • 3
  • 37
  • 58
0
votes
1 answer

A synchronous Breeze ExecuteQuery

I get data form the DB like this using Breeze promise ExecuteQuery : var getdata = function(){ var manager = new breeze.EntityManager(serviceName); var query = new EntityQuery().from('MyTable'); manager.executeQuery(query) …
dafriskymonkey
  • 2,189
  • 6
  • 25
  • 48
0
votes
1 answer

Breeze to$q: $log is not defined

If you tack a "fail()" on one of breeze's Q that doesn't re-throw the error, it tries to log a message to tell you that. It says (line 58 of breeze.to$q.js: https://github.com/IdeaBlade/Breeze/blob/master/Breeze.Client/Scripts/Labs/breeze.to%24q.js)…
0
votes
1 answer

Any analogue for Q.anySettled promise in JQuery?

Shortly about the task. We have an array of promises that could either resolve or reject. To understand whether total result is good or not - we need to know results of all promises in array. In JQuery (our usual go-to library for promises)…
North
  • 107
  • 1
  • 12
0
votes
1 answer

Why does deferred.resolve not behave as specified in the q manual?

This may be a stupid question, but I am unable to wrap my head around this. Consider the following piece of code: function throwError() { throw Error("can't touch this."); } var def = q.defer(); def.promise.then( function() { …
raffomania
  • 451
  • 4
  • 14