A lightweight Promise and when() implementation, plus other async goodies.
Questions tagged [when-js]
62 questions
2
votes
1 answer
How to use when.map with node.lift-ed function?
I'm learning promises with when.js library, and using when.map with node fs.readFile makes me think I missed something.
foo promise works ok when called as a single promise, but fails when used as a mapper function in when.map because index is…

Slava Nadvorny
- 151
- 3
2
votes
1 answer
Promises: Refactoring Progress when the number of progress updates is unknown
The progress handler has been deprecated in a few of the leading promise libraries (Q, When, Bluebird), and has also been dropped from the new Promises/A+ spec. Though I understand the reason behind doing away with progress events, I'm having…

Chitharanjan Das
- 1,283
- 10
- 15
2
votes
0 answers
when.js Promise: then() callbacks is never called
I have: code snippet like this:
Utils.calculate(data).then(
function(data) { alert('success'); },
function(data) { alert('error'); }
);
Problem: Neither 'seccess' nor 'error' are called.
Question: What I should to check?
P.S. I launch those…

VB_
- 45,112
- 42
- 145
- 293
2
votes
1 answer
Synchronize promises created asynchronously
I'm working on a little nodejs program and have some troubles to know when all async operations of the program are completed.
For now, the program do the following steps:
1/ Spawn a process with some parameters. This process will print data on its…

Pierre-Yves
- 443
- 3
- 9
2
votes
1 answer
A different way of handling this promise?
Here's a little bit of CoffeeScript, but feel free to answer in JavaScript:
model = new MyModel content: content
model.save()
@collection.add model
Elsewhere, a view is listening for the add event on the collection:
_addOne: (model, collection,…

ian
- 12,003
- 9
- 51
- 107
2
votes
2 answers
either 'when-js' or basic amqplib rabbitmq nodejs tutorial not working
I have the latest version of nodejs (0.10.21, amqplib (0.1.0)(https://github.com/squaremo/amqp.node.git) and rabbitmq (3.2.0).
start rabbitmq-server
go to amqp.node/examples/tutorials and run ./send.js after installing npm packages.
it reports:
…

Rene Wooller
- 1,107
- 13
- 22
2
votes
2 answers
Converting node async code to promises
I'm experimenting with promises - namely when.js - and want to convert some test code - a little unclear how to do it even after reading docs. My experiments so far have been far messier than standard callback pyramids so I think I am missing some…

cyberwombat
- 38,105
- 35
- 175
- 251
1
vote
1 answer
JQuery.when multiple JSON variables
I have this code which retrieves JSON using $.getJSON() from 2 URLs and saves the results as variables. I then use $.when() and then() to get the data from these variables. However, this only works when I do one at a time, each with it's own…

Alex Boullé
- 431
- 5
- 17
1
vote
1 answer
Need correct call to Promise reduce (when.reduce )
I have a processor function that takes a "cmd" object and returns a promise where the resolution is the same "cmd" object passed in (with a response key added). reduce here is when.reduce
reduce = require('when').reduce;
//return…

DKebler
- 1,216
- 1
- 15
- 27
1
vote
1 answer
What is the difference between `when(foo, f)` and `when(foo).then(f)`
I'm looking at some existing code that uses when.js. A pattern that appears a few times is:
return when(someBigFunction(), function() {
doSomeMoreProcessing();
if (maybe) {
throw someError;
}
});
I imagine the reason they use when here is…

Steve Bennett
- 114,604
- 39
- 168
- 219
1
vote
0 answers
using reqwest and when for making remote calls
I am using nodejs modules reqwest and when for making the remote calls and the promise returned is a failure.
How ever when i use postman to submit the same request i am getting the response back.
I am not sure why the promise is getting…

Sateesh K
- 1,071
- 3
- 19
- 45
1
vote
1 answer
Is there a way to go from Jquery Deferred/Promise to When-JS Promise
I would like to use When-JS capability out of the promise returned by a jquery ajax call. Is there a conversion scheme ?
Edit 1
https://github.com/cujojs/when/blob/master/docs/api.md#api

MaatDeamon
- 9,532
- 9
- 60
- 127
1
vote
2 answers
deferred object returning before resolving
I am using the when library with Node js. I create a deffered object, place the resolve inside an encapsulated Mongoose findOne() function, and return the promise outside. But it seems my promise is always returned before the data is…

forty2011111
- 115
- 7
1
vote
2 answers
Chain promises with then()
I'm using the when promise library to lift() my node style callbacks and promisify them...
var nodefn = require('when/node');
var one = nodefn.lift(oneFn),
two = nodefn.lift(twoFn),
three = nodefn.lift(threeFn);
function oneFn(callback){
…

Drahcir
- 11,772
- 24
- 86
- 128
1
vote
0 answers
How to hide and show table rows in XSL file according to the string returning null or not from JS file
content is extracted from javascript function where enhanceddetails is declared and fetch in node type.I want condition when enhancedetails is nt selected and its returns null.. so its row will disappear.
XSL file

user4315698
- 11
- 3