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

Angular construct ViewModel from different promises

In my Angular project i have a Promise that returns an array of Products: {"Products":[{"Code":123},{"Code":456}]} Then for each product code, i must call two other promises that return Price and Quantity respectively. I use ui-router and my…
Ricky Stam
  • 2,116
  • 21
  • 25
0
votes
1 answer

q node.js, callback after mongoose's "post"

I have this source code: UserSchema.post('save', function (next) { doSomethingAsync(function(){ next() }); }); myFunc = function(user){ Q.ninvoke(user, 'save').then(function(){ doThisAtTheEnd() }); } But then is…
M4rk
  • 2,172
  • 5
  • 36
  • 70
0
votes
1 answer

Q.js and order of execution confusion within ASP.NET MVC

I have adopted the library Q.js into my program to try and solve some problems with the order of execution in my code, I am new to promises and deferred in general, so this is a pretty difficult step for me. At this point in time, I am using Q v1…
Ciel
  • 4,290
  • 8
  • 51
  • 110
0
votes
1 answer

Node.js Abort chain in Q in different point

I have a pretty long chain of check in Q, and I would to interrupt it when an error rise: I have looked to How to abort a failing Q promise in Node.JS and other answers on SO, but it seems impossible to me, that can't exist nothing…
M4rk
  • 2,172
  • 5
  • 36
  • 70
0
votes
2 answers

How to access data from callback

I have written method called getChildren to get data related to id, but I am unable to access that data in caller method. My sample code is as follows I have written these two methods in controller and Passed all objects which are necessary var…
IfOnly
  • 540
  • 1
  • 4
  • 17
0
votes
2 answers

Abort AngularJS $http request, deeply nested in multiple service calls

I'm using a deferred promise to abort a $http request (like explained in this post). However, I'm unsure of how I should propagate the abort() function added at the root level. Everytime I call .then() on the promise, a new promise (without the…
Joel
  • 8,502
  • 11
  • 66
  • 115
0
votes
1 answer

cca per groups and row.names

I am somewhat new to R, so forgive my basic questions. I perform a CCA on a full dataset (358 sites, 40 abiotic parameters, 100 species observation). library(vegan) env <- read.table("env.txt", header = TRUE, sep = "\t", dec = ",") otu <-…
nouse
  • 3,315
  • 2
  • 29
  • 56
0
votes
1 answer

AngularJS - Deferred recursive promises

I have a function that calls an asynchronous function (in a loop) that will provide me a parameter for the next call of the function. I think writing the code will make more sense so here is what I tried (with no success). I know many questions have…
Nate
  • 7,606
  • 23
  • 72
  • 124
0
votes
1 answer

Where to put "Q.longStackSupport = true"?

From the documentation of Q (the Javascript promise library): Q.longStackSupport = true; This feature does come with somewhat-serious performance and memory overhead, however. If you're working with lots of promises, or trying to scale a server to…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
0
votes
2 answers

Promises in a for loop, do something when done

Basically, I'm trying to figure out a way to do a bunch of queries in a for loop and then do something once they've all completed. I got it to work, but only because I used this great library that wraps all of mongodb with promises. var mongo =…
Nick Lang
  • 469
  • 6
  • 16
0
votes
1 answer

Export q from angular?

For debug purposes I need to export a $q service out of angular object from global js scope or console. Is there any way to do that ? Pseudo code: var q = voodoo(angular); or var q = angular.DO().$something
c69
  • 19,951
  • 7
  • 52
  • 82
0
votes
2 answers

node's q.fcall returns an empty object

In the node shell I see this: > console.log(JSON.stringify(Q.fcall(function() { return 10 }))); {} undefined HOwever the docs for q here :Q say that it returns a promise, which is an object with an apply() and a then() function. So why is this…
Cheruvim
  • 127
  • 1
  • 5
0
votes
2 answers

What is the difference between calling a node function (that returns a promise) directly vs using ninvoke

In the code below when i call using ninvoke the "then" part does not get executed. The result is as follows calling thru a function that uses ninvoke dbConnect --> Success: Connected to db! calling directly dbConnect --> Success: Connected to…
0
votes
1 answer

Can't bind to angular repository data with promise

I'm trying to use the repository pattern with Angular. When I call my repository, I can see that the json is returned over the network. But I can't bind to it. I'm injecting the repository into the module... what's…
Hoppe
  • 6,508
  • 17
  • 60
  • 114
0
votes
3 answers

Javascript promise conversion

I'm having a hard time understanding how promises works. I've seen some examples and some of it makes sense. However, when I try to actually use it I get stuck. I have the following example: (I'm using q and nodejs. getItem() returns a promise, but…
user3582665