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

Difference between 2 implementations of promises

I use promises in my website (still learning) and I would like to know if there is a difference between this: return promise .then(ctxTransport.getTransportById(idTran, transport)) .then(checkLocking) …
Bronzato
  • 9,438
  • 29
  • 120
  • 212
0
votes
1 answer

Combining a synchronous function while using Q's deferred/promise

I'm doing a bunch of deferred/promises with the Q library which works fine, but once I get back some of my data in one of the chained callbacks, I want to manipulate it in some way. E.g. var getFavorites = function(submissionId) { deferred =…
bob_cobb
  • 2,229
  • 11
  • 49
  • 109
0
votes
1 answer

Hot Towel - Does Durandal need to be patched to use Q instead of jQuery promises?

In working on my first SPA application based on John Papa's Hot Towel template, I ran across a note that suggest that Durandal uses jQuery promises, whereas all the other libraries in Hot Towel use Q for promises. Durandal does have a page that…
0
votes
1 answer

Why does my Q chained promise rejection not behave the way I expect?

What am I doing wrong here? I have a piece of code that looks something like this: function getUserList(requestingUserId){ return customerRepo.getCustomersAllowedByUser(requestingUserId) .then(function(customers){ return…
0
votes
1 answer

jQuery async calls on array

I'm trying to get the following scheme to work: I have a an ajax call that returns an array of objects (promise). Now, I have a succeeded function that does additional handling on each item in the array, including making other async ajax calls. Of…
Ali B
  • 1,097
  • 1
  • 14
  • 27
0
votes
1 answer

Equivalent behaviour of 'jQuery.active' in q

In my c# selenium webdriver tests I occasionally have to make use of: public void WaitForJQuery(TimeSpan timeout) { var wait = new WebDriverWait(driver, timeout); wait.Until(d => (bool)(d as IJavaScriptExecutor).ExecuteScript("return…
ash_s
  • 85
  • 2
  • 8
0
votes
0 answers

Scope variables changed by promise do not update dom

I am fairly new to AngularJS so bear with me. I am trying to implement a gallery slider type app, but I need the page to load and do stuff before all the images load because they are quite large and there may be a lot of images.I am trying to do…
Brandon
  • 830
  • 1
  • 15
  • 35
0
votes
2 answers

BreezeJS breaks Q promise on fail save

When query execution fails (for example database constraint violation on saving) i can see in console. Should be empty: [] Here is the example (you can see Should be empty: [] in console)): breeze.EntityQuery …
The Smallest
  • 5,713
  • 25
  • 38
0
votes
1 answer

How to simply change q.js-promise 'errormessage' on reject?

I'm using Q.js for promises. I'd like to know if it's possible to quickly format/change the error-message when a Q-promise fails. Consider the contrived example: return Q.when(//$.ajaxpromise for instance).then(function(result){ …
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
0
votes
2 answers

How to update file upload messages using backbone?

I am uploading multiple files using javascript. After I upload the files, I need to run several processing functions. Because of the processing time that is required, I need a UI on the front telling the user the estimated time left of the entire…
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
0
votes
1 answer

I need some help promises and q library

I need some help on syntax with node.js promises. In readme for node.js module called q https://github.com/kriskowal/q is written something I don't understand. Why do they always write return before promise? return Q.fcall(eventualAdd, 2, 2); How…
useruser
  • 3
  • 3
-1
votes
1 answer

MongoDB indexing , please explain difference between 1 and -1

mongoDB document example has two fields userid and score. And while indexing in mongoDB for userid , 1 value provided and for score its -1, i.e. { userid: 1, score: -1 }. Please explain here the difference between 1 and -1 in mongoDB indexing. I…
-1
votes
2 answers

Function to Convert decimals to percentage in KDB

`pct:157.35686 func[`pct] func::{[x] ?[x>1;x-100;100*x]} The result should be as 57.35% `pct:0.804892 func[`pct] func::{[x] ?[x>1;x-100;100*x]} The result should be as 80.48%
coderinq
  • 15
  • 1
  • 4
-1
votes
1 answer

How to write function/trigger that grabs single values from queries for a boolean expression

I am working on a mock airline ticket reservation app using javascript and a postgres database. --EDITED-- I need to create a function/trigger that will only allow me to insert a new row in my TICKET if the number of tickets for a flight does not…
-1
votes
2 answers

"this" inside prototype takes window instead of object

I created an Object called Survey and added a prototype function to it, and when I console log this inside the prototype function the log shows window object instead of parent Survey Object. function Survey(questions = []) { this.__questions__ =…
Vinayak humberi
  • 191
  • 3
  • 8