A lightweight Promise and when() implementation, plus other async goodies.
Questions tagged [when-js]
62 questions
1
vote
1 answer
when/node liftAll not working on s3 object
I'm trying to lift all the functions in an Amazon S3 object using when/node.
var when = require('when');
var nodefn = require('when/node');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var promisedS3 =…

Cody
- 1,178
- 3
- 12
- 26
1
vote
1 answer
How do I use DDPClient with promises?
I am trying to use when.js with ddpclient. The code I have written is at the bottom of the post. When I attempt to use this, I get the following error below. Any ideas on how to get around this error? I am aware of another DDPclient that uses…

user1074891
- 279
- 3
- 14
1
vote
0 answers
promises not getting resolved while testing directive using jasmine
I am currently testing a custom directive which uses promises.
The structure of the first part of code segment of the directive is as follows:
angular.module('app').directive('simpleMock', [
'$q',
function ($q) {
'use strict';
return {
…

user2099863
- 121
- 1
- 1
- 3
1
vote
1 answer
How do I convert this lazy assignment via ajax into a promise?
I looked at this question about caching and this one about conditional promises but to be honest, I'm still a bit confused, as I've never used promises before.
I'm using when.js v2.5.1 and jQuery v2.0.3. I'm trying to convert the following code into…

ian
- 12,003
- 9
- 51
- 107
1
vote
2 answers
Getting dependencies to load correctly in requirejs (autobahn and whenjs)
I have been stuck on this problem for the past few hours. I'm trying to get autobahnjs and whenjs to be loaded correctly by requirejs.
require.config({
paths: {
angular: '../bower_components/angular/angular',
…

Flukey
- 6,445
- 3
- 46
- 71
1
vote
1 answer
when.all() 2.2.1 in cujojs doesn't reject if one deferred rejected
I am having trouble working out why a promise is being fulfilled when the documentation says it should be rejected.
Open http://jsbin.com/orifok/5/edit and click the go button, and it alerts "ok" when it should alert "fail".
Replace when221.all...…

robocat
- 5,293
- 48
- 65
1
vote
1 answer
With when.js how can I convert a promise to a Node.js style callback?
I'm using IcedCoffeeScript.
I want to write this:
User.find(id).always esc done or await User.find(id).always defer e, user
But Promise#always is deprecated in when.js.
Is there another way?

vaughan
- 6,982
- 6
- 47
- 63
0
votes
0 answers
How can Ajax wait for user input?
I tried to write a programm, which takes javascript input and passes it over to python via ajax. Somehow the programm just runs through without noticing the user input. This is the code I have written so far...
$.when(returnText()).done(function(){
…

noooooo
- 11
0
votes
0 answers
Import 'when' in TypeScript
Is there a way to make use of the when framework in TypeScript?
In JavaScript I can import it like this:
import when from 'when';
But doing the same in TypeScript leads to this error:
Cannot find module 'when'. Did you mean to set the…

Socrates
- 8,724
- 25
- 66
- 113
0
votes
1 answer
How to install library 'When' in Javascript
I have got 2 files: index.html and index.js. I am using them to try and do autobahn communication. Autobahn works, but 'When' doesn't work.
I have used bower to download and install Autobahn, and then manually included autobahn.js from withing the…

Kristijan Čeple
- 9
- 4
0
votes
1 answer
How to run get json and save as a variable, then use it in other methods
I want to parse a JSON file, then store its data in a variable and use it in different part of the code.
I think for this purpose I should use $.when().done(). However, I I do not know how to pass data.
The following code is not function but it…

Danny
- 79
- 3
0
votes
1 answer
jQuery: Make second function wait to execute, until first function is complete
I'm trying to use when and done to make the second function run only after the first one is executed, but it's not working.
What I'm trying to achieve here is:
First I use $("#jobshome").load("jobs/newest-jobs .js-toprow"); to load a div from an…

Matt
- 15
- 9
0
votes
1 answer
$.when($("").function() == true).then() not working as expected
I have a function which returns true or false. Now I'd like to execute some code once the function returns "true".
The function determines if an element is visible on screen. I took it from here.
The element is displayed 1-2 seconds after the page…
user7354305
0
votes
0 answers
How to use when/parallel
I'm a bit stumped at what I might be doing wrong when I'm trying to use the when.js parallel function:
https://github.com/cujojs/when/blob/master/docs/api.md#whenparallel
var parallel = require('when/parallel');
var resultsPromise =…

blub
- 8,757
- 4
- 27
- 38
0
votes
1 answer
Way to easily bundle JavaScript files which contain require instructions
Is there some application that can automatically bundle (and minify) JS projects that have require('file.js') calls in them? So that they are merged and one single file is produced.
Specifically I am talking about when.js, a JS library with a lot of…

Kirschi
- 1,088
- 3
- 12
- 32