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

Durandal issue with Breeze and Q

Hi i'm new to building web pages applications, i started with HotTowel videos from John Papa and used initially the HotTowel VSIX Template. When i decided to update to Durandal 2.0 i faced the issue that the application would not proceed from the…
forcewill
  • 1,637
  • 2
  • 16
  • 31
0
votes
3 answers

What is the when.js equivalent of Q.js's "done()"?

In addition to then(), Q.js also has a done(). done() is usually called at the end of a promise chain, like this: promise .then(callback) .then(callback) .done(callback); This will catch any rejections that were not handled by the previous then()s,…
Matt Zukowski
  • 4,469
  • 4
  • 37
  • 38
0
votes
3 answers

Resolve promise based on another promise

I've a function, which returns a promise, inside that I call another function, and the status of this promise is based on the status of the inner promise. Is there a way to shorthand this process. Look at the example below. function foo(bar) { …
sowdri
  • 2,193
  • 5
  • 23
  • 36
0
votes
1 answer

Angular and Breeze fetchMetaData

I'm curious if there are any alternatives to fetching meta data from breeze when using Angular. Since $q and Q promises don't play nice with each other I decided to only use Q.js promises and not $q. In my controller I'm checking if the…
pehaada
  • 513
  • 2
  • 8
  • 20
0
votes
1 answer

Collection navigation properties may NOT be set on ICollection property

I have two clases in relation one-many: public class ClasssA { public int Id { get; set; } public int ClassBId { get; set; } public virtual ClassB ClassB { get; set; } } public class ClassB { public int Id { get; set; } …
Mariusz
  • 442
  • 5
  • 16
0
votes
1 answer

Chain parameters between async functions with Q in node.js

How can I chain the parameters that I need for my both async functions. The first function fs.readFile returns the content of the file in the callback function as second parameter. The second function marked requires this content as first parameter.…
Jan Baer
  • 1,105
  • 1
  • 12
  • 15
0
votes
2 answers

Why does this resolved Q promise responds to valueOf() with a promise?

I have an object whose value comes from an AJAX request. I'm converting it to a promise and am encountering some behaviour with promises that I don't expect. I have an example here that exhibits the same behaviour, but I'm substituting Q.all() for…
Gregory Bell
  • 1,861
  • 1
  • 19
  • 21
0
votes
1 answer

Arithmetic operations in ASM Language

I just need some help. I don't fully understand and I am fairly new to masm32 so if you could explain, that would be great! MOV AX, 200 ADD AX, 300 MOV RESULT, AX Will result be equal to 500? I tried adding 3 and 2 and using this to show…
0
votes
1 answer

AngularJs scope attributes and promises

I have this code: var geocode = function(value) { var request; ..... var dResult = Q.defer(); geocoder.geocode(request, function (results) { dResult.resolve(results); }); return dResult.promise; }; var cancelWatch; $scope.$watch('value',…
nicco82
  • 179
  • 2
  • 9
0
votes
1 answer

$resource and $q to set dropdown init value

I have a data service that says: myApp.factory('locationsData', function ($resource) { return $resource('/api/Location/:id', { id: '@id' }, { update: { method: 'PUT' } });}); I then use these locations to populate a dropdown in my view:
user2375056
  • 55
  • 1
  • 5
0
votes
1 answer

Cancel a query in Breeze JS

Is there some way to cancel a query I'm running in BreeseJS. I don't really care if the query runs server side, but it would be nice if I could just call a method or something to make sure that it doesn't call the method I have assigned to the…
Nocklas
  • 1,367
  • 4
  • 15
  • 27
0
votes
1 answer

Generate random with uniform distribution in some range

how can I generate random number with uniform distribution in some range i.e [a, b] using q? I have found some solution, but truly speaking I don't know how to rewrite it, because those solution generate random numbers in range…
myrkul
  • 33
  • 1
  • 6
0
votes
1 answer

node.js & promises: Common practice?

I am new to node.js and am currently setting up the environment, choosing which modules I will use etc. During my research I found the Q module - which I really appreciate because of both the simplicity of the code and the structure itself. I…
Christopher Will
  • 2,991
  • 3
  • 29
  • 46
0
votes
1 answer

Using Q to recursively generate a chain with multiple subchains

Basically, I'm trying to set up a tree, where each node has a reference to it's parent. I've tried the following: function insert_node(node_data, parent_id) { var deferral = Q.defer() deferral.promise.then(async_create_node(node_data,…
CSturgess
  • 1,547
  • 2
  • 13
  • 29
0
votes
1 answer

Restify.js (Connect/Express) middleware ignoring call to next() within promise callback

So. I'm experiencing some quirks when attempting to implement some basic middleware for a Restify.js application I'm building with specific regard to next() and promise callbacks. To express the problem in a generic form: var server =…
Matt Richards
  • 1,477
  • 2
  • 14
  • 21