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

what is the alternative for $q or Q in angularJs

I have been using $q for quite sometimes, it is working all fine. But lately for web workers the injection of $q is causing an issue. The Mangled, minified q.js is not able to detect functions which are used by Parallel.js. So is there an…
Sammi
  • 109
  • 3
  • 11
-1
votes
2 answers

how to make synchronous http calls using promises in node.js

I would like to iterate thru an array of students and make http call for each of them and parse the response and insert into mongodb, so I would like to do this for each student one by one untill all data are inserted then continue with the next one…
Lulzim Fazlija
  • 865
  • 2
  • 16
  • 37
-1
votes
1 answer

C# OPC client shutdown

I'm novice at OPC and I'm making an OPC client on C#, and testing it at Matrikon OPC server. And i have a question, how could i shutdown connection with the server when program made it's business ? Cause I notice when I'm finishing my program it's…
Jam
  • 101
  • 11
-1
votes
2 answers

How to return the last value in Q javascript

Hi there im new to writing promises in javascript. I want to return a value from func1 which are composed of then (using q) calling other functions resolving the value then passing to through the next function. The problem is i want to return the…
Kenichi Shibata
  • 148
  • 2
  • 11
-1
votes
1 answer

how to use defer/promise in javascript for a db call

I am having db.js with db related functions, I want to make call to db.js and wait until it returns the query result. But the result is returned after the execution of the db call. Can anyone please help how to solve this. Code sample: var Q =…
-1
votes
1 answer

About terminating a dynamically constructed sequence of promises

I wrote a script in Node that iterates over a large MongoDB collection, returning a certain number of documents at a time. The collection has this simple format: { name: 'One', data: '...' }, { name: 'Two', data: '...' }, ... I'm…
kYuZz
  • 1,572
  • 4
  • 14
  • 25
-1
votes
1 answer

Is there a built-in function to configure a race in q?

Is there a built-in function to configure a race in the q JavaScript library? Example: function fnThatReturnsAPromise1() { /*...*/ } function fnThatReturnsAPromise2() { /*...*/ } //Pseudocode: I want to have the first one of these functions that…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
-1
votes
1 answer

Relay Q promise results to another promise

I'm using Q together with RequireJS. Oftentimes I find myself writing code like this: function someFunc() { // prepare result var res = Q.defer(); require( ['someOtherModule'], function( mod ) { // do some stuff with mod mod().then(…
Sirko
  • 72,589
  • 19
  • 149
  • 183
-1
votes
2 answers

Call to modules in specific order in node

I've used the following code to call two modules, but the invoke action is called before the validate file (I saw in debug). What I should do to verify that validateFile is called before appHandler.invokeAction? Should I use a promise? var validator…
user4445419
-1
votes
1 answer

Resolve promise using promise implementation of node package

I am using the uci node package which uses the Q library for promises in their source and thus makes the following promises possible, but I can't resolve the promise and propagate outputPromise due to deferred.resolve() not being defined. How would…
Henry Boldizsar
  • 489
  • 1
  • 8
  • 25
-1
votes
2 answers

Q.js not working in Firefox

I wrote a small JavaScript application using the Q.js library, which works fine in Chrome, but not in Firefox. I get the following error: Error: Script terminated by timeout at: Promise.prototype.then@https://rawgit.com/kriskowal/q/v1/q.js:832:1 …
David Brochart
  • 825
  • 9
  • 17
-1
votes
1 answer

call functions in async with node which is more recomended Q or callback

I've node app with function that inside call to to other two function,I want to use some async behavior for it,what is recommended to use in this case. example will be very helpful. function myFunction(req,res){ //from here this is the first place…
user4445419
-1
votes
2 answers

Javascript promises and callback function

So basically can anyone briefly go through with me what's the difference between user.login(username,password,function(){ //do something here }); and user.login(username,password).then(function(){ //do something here }); Which one should…
Peter.Wang
  • 2,051
  • 1
  • 19
  • 13
-1
votes
1 answer

How to use Q.js with breeze

This is my first attempt at using q.js. It appears to work, I have data being retrieved and then my function is called. The problem is the data is not being passed to the function. Is it a syntax problem or am I misusing Q? getCategories =…
user1068557
  • 309
  • 2
  • 8
-1
votes
1 answer

what is the benefit to use Q defer?

I am new in Q. lib When do we need to use Q.defer ? what is the benefit? can we return promise with q.defer? var deferred = Q.defer(); FS.readFile("foo.txt", "utf-8", function (error, text) { if (error) { deferred.reject(new Error(error)); }…
user1365697
  • 5,819
  • 15
  • 60
  • 96