Questions tagged [when-js]

A lightweight Promise and when() implementation, plus other async goodies.

62 questions
8
votes
1 answer

Cascading promises

Anything beyond a simple promise usually has me perplexed. In this case I need to do 2 asynch calls in a row on N number of objects. First, I need to load a file from disk, then upload that file to a mail server. I prefer to do the two actions…
GreginNS
  • 161
  • 2
  • 7
7
votes
2 answers

Error turning Amazon S3 function into promises using when/node

I'm trying to lift an AWS S3 async function, and running into a weird error. Given the following code, var s3 = new AWS.S3(); var when = require('when'); var nodefn = require('when/node'); var getObjectP = nodefn.lift(s3.getObject); getObjectP({ …
Cody
  • 1,178
  • 3
  • 12
  • 26
6
votes
1 answer

trap when.js unhandled rejections

I'd like to trap when.js unhandled rejections so that I can log them. To accomplish this I've overriden console.warn(), however that can log stuff other than when.js which I'm not interested in. ref:…
nevf
  • 4,596
  • 6
  • 31
  • 32
6
votes
2 answers

How to use catch and finally with when.map

I want to use the when.map function to process some data. After the data is processed I need to do some cleanup (e.g. release the currently used database connection back to the connection pool). The problem with my approach using catch and finally …
t.niese
  • 39,256
  • 9
  • 74
  • 101
6
votes
4 answers

How do I dynamically add a deferred to the promise from this jsFiddle?

Regarding this jsFiddle, I am trying to dynamically add a "deferred" which is created when an event triggers, so the done callback is only called when all deferred are resolved, including those added later: Relevant code: var promises = […
Hontoni
  • 1,332
  • 1
  • 16
  • 27
5
votes
1 answer

'Zombie promises' continuing after a mocha.js test timeout

I'm using a testing setup with Mocha.js and a lot of promises within the tests. The tests depend on setting up stuff in the DOM, and between tests, the DOM is cleared. However, sometimes the tests run slowly and time out. In this case, their…
dandelion
  • 1,742
  • 1
  • 15
  • 18
4
votes
1 answer

Callback pyramid even with When Promise

I have 3 functions that I want to execute one after another, only when the previous function has finished its task. I use When Promise library for this, function taskA(){ var d = when.defer(); d.resolve(); return d.promise; } function…
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
3
votes
1 answer

How to fetch a list of objects and wait for them to finish?

I have a list of urls to follow and would like to store the result in an array. Current implementation is to use map to fetch and when.all to wait. Like below: const when = require('when'); }).then((responseJson) => { …
LOUDKING
  • 301
  • 1
  • 13
3
votes
2 answers

Promises and upserting to database in bulk

I am currently parsing a list of js objects that are upserted to the db one by one, roughly like this with Node.js: return promise.map(list, return parseItem(item) .then(upsertSingleItemToDB) ).then(all finished!) The problem is…
blub
  • 8,757
  • 4
  • 27
  • 38
3
votes
1 answer

Skip to next exception point in non-blackboxed file

I'm trying to debug some code that uses when.js. Stepping through code, at a certain point, I arrive in when.js itself, and then get buried in a long sequence of internal calls - promise fulfillments, queueing etc. I have when.js blackboxed, but…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
3
votes
1 answer

node.js mongoose.js memory leak?

I'm creating bower package search site (everything is open sourced) and I hit the wall. I have some memory leak (or I think I have) and I honestly don't know why it is there. You can download it and run on Your own, but simple hint will help me…
Kamil Biela
  • 706
  • 1
  • 6
  • 13
2
votes
2 answers

Why is Angular 2's template not updating from calls outside an angular zone?

I thought I would create a very simple login form with component-bound username and password properties that would run through the following steps: Submit credentials with a fetch() call THEN obtain the Response result object's JSON content THEN…
dgbonomo
  • 153
  • 8
2
votes
1 answer

Wait for d3 to load

I am creating a pie chart using d3 to load a pie chart - var pie = new d3pie( // pie control Json ); This is working great however I am looking to do logic after the pie has fully rendered. I have tried to use the when done logic (like when…
Ebikeneser
  • 2,582
  • 13
  • 57
  • 111
2
votes
1 answer

Mongoose distinct with promises

i use when.js as a promise library for mongoose and try to get distinct filed of collection and return result as promise mongoose.Promise= require("when"); function getPromisedDistinct(startDate, endDate) { return…
user5318264
2
votes
0 answers

Process unhandled rejections in Node.js

Follow up question re. trap when.js unhandled rejections the Node.js process.on() example prevents the normal console/prettymonitor output from displaying. Is there a way to retain this. Also the docs show: process.on('unhandledRejection',…
nevf
  • 4,596
  • 6
  • 31
  • 32
1
2 3 4 5