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

how to check error in qunit

I have a function in JavaScript that uses the q library: validateOnSelection : function(model) { this.context.service.doLofig(model).then(function(bResult) { if (bResult) { return true; } else { throw new…
user1365697
  • 5,819
  • 15
  • 60
  • 96
-1
votes
1 answer

Is changing the meaning of promise methods a good idea?

I have a long running method in Node.js that keeps listening for command line output until the user closes the command or an error halts. Long story short, this method had, among others, three callbacks: on_receive: Returns any new output from the…
Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
-1
votes
1 answer

Angular $q and $http for data binding not working

I'm trying to make a basic data pulling using a service and print it on screen when I have data, but something is not working. My service: mymodule.factory('MyService', function($http, $q) { var service = { getData: function() { …
Ben Diamant
  • 6,186
  • 4
  • 35
  • 50
-1
votes
3 answers

Sequencing async operations followed by onResult call

Fiddle: http://jsfiddle.net/smartdev101/eLxxpjp3/ Inside asyncAction function call, a promise has been created to sequence two async operations, getRecords and getTotal followed by a final call to onResult(data) on success or onFail(info) in case…
user2727195
  • 7,122
  • 17
  • 70
  • 118
-1
votes
1 answer

ReferenceError: Strict mode forbids implicit creation of global property in for loop on promise

I am having a really strange problem. I am trying to perform a for loop on a promise return value. When I run the code from a jasmine test it breaks. When I run it from a browser it breaks. The code…
Exitos
  • 29,230
  • 38
  • 123
  • 178
-1
votes
1 answer

Is there a need to break down mini functions in my node.js controller?

I have a controller for say users where I sign up my users. Do I really have to break up the steps of the sign up as below and do they all asynchronously seperately or is one big asynchronous call ok? Each step is kinda dependent on the…
user3428172
  • 147
  • 2
  • 6
-2
votes
1 answer

Angular promises executing then in the beginning and not after all other promises

The code below does not throw a syntax error, but the THEN statement which renders the data on the datatable is executing first, before all lists have been queried What is the intention of this code, there are many sharepoint lists with similar…
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
-2
votes
1 answer

How to promisify a function using q and how to manage error handling?

I have a function which i have promisifed using 'es6-promisify'. I want to replicate the functionality using 'q'. Here is a sample code which i'm using: const promisify = require('es6-promisify') function asyncFunction (done) { …
Sarvesh Redkar
  • 113
  • 1
  • 2
  • 11
-2
votes
1 answer

How to start using $q?

I've tried to inject $q in my controller like this: app.controller('NodeCtrl', ['Tree', function(Tree, $scope, $element, $q) { But, $q is not defined, how can I start using it? I am using Angular 1.4
Samir Sabri
  • 937
  • 3
  • 11
  • 26
-3
votes
2 answers

how to use dictionary as a database for passwords in python

print("Please confirm your identity user(lower case):") pins = {"abra":9999,"anna":1888} name = input("") print("Now please confirm you pin:") pin = int(input(">>")) if pin == pins.value[0] and name == pins.keys[0] print("You are great") elif…
-3
votes
2 answers

Nodejs best way for synchronous execution?

What is the best way for synchronous execution when working with external modules? I would like the output to result in: Setp 1: Hello Setp 2: Hej Step 3: Hola Step 4: Bonjour Example: //File: main.js var greetings =…
-3
votes
1 answer

What is the lexical scope of the success callback of the 'then' function of an angular promise?

I'm trying to understand why some of the dependecies injected (or other variables declared) in my controller are not available inside the success/error callback of the 'then' function of a deferred promise. I've searched in angular $q's…
DiegoA29
  • 1
  • 2
-3
votes
1 answer

Best practice to handle exception when using Q.promise

I have the following method: module.exports.getId = function(someObject) { var myId = null; return Q.Promise(function(resolve, reject, notify) { // Loop through all the id's someObject.user.player._id.forEach(function (id)…
Catfish
  • 18,876
  • 54
  • 209
  • 353
-3
votes
1 answer

Alternative way to create a promise with q

I know how to create a promise in Kris Kowal's q with var defer = Q.defer();, calling defer.resolve(); and/or defer.reject() and return defer.promise. But reading the docs, it seem's there is an alternative way to create a promise... From the…
Christian Rädel
  • 581
  • 1
  • 5
  • 13
-4
votes
2 answers

Can I "rename" the methods 'then' and 'catch' when I'm returning a promise?

I would like to change the name and write "exito" (success in spanish) instead of .then() and "error" instead of catch(). Here is my code. How can I manage with this? var url = 'http://devmsadasds'; var object = null; var…
1 2 3
92
93