"Promises" are a particular tactic for deferred computing, suitable for several styles of concurrency: thread and event loop concurrency for local computation, and both synchronous and asynchronous remote messaging.

learn more… | top users | synonyms (1)

0
votes
1answer
81 views

Using promise all with push array

The code's purpose is to call to some function async given some condition was true. I've using the following code which is working as expected. Is there a way to write it better, maybe by not using ...
1
vote
0answers
30 views

Node.js MySql code using Promise API

I have written a javascript code for fetching data from mysql database. I have used connection pooling, and Promise API also. the code is as follows, ...
1
vote
1answer
36 views

From Callbacks to Promises - MEAN Stack

I have a MEAN Stack app in which I have been using mongoose routes to update my data. Some of those routes have a lot of back and forth in terms of updating data across multiple users and collections. ...
2
votes
1answer
73 views

Check deep object property and find duplicate value

I use the following code to find if there is duplicate value in property path: ...
1
vote
1answer
49 views

Promise Chaining for a Firebase v3 Auth Subsystem - Password Based Users

Firebase v3 Offers Authentication via 3rd party oAuth providers, facebook, github,google, and twitter. They also offer password pased authentication. Authenticated users have a firebase.User object ...
1
vote
1answer
36 views

Angular Promise trying Wrapper

Sometimes I need to repeat an execution of rejected promises several times, for example, to fetch some data over internet. There is a wrapper, which accepts Promise and tryCount: ...
3
votes
1answer
46 views

JSON API client to manage user accounts

I have the following class in Typescript (using the Aurelia SPA-framework). ...
0
votes
0answers
68 views

Saving an object using a promise chain

This here is some fairly simple functionality The user has a list of objects, which they modify, or may create a new object. When the user presses 'Save/Update' the 'saveClick()' function is called. ...
1
vote
2answers
54 views

Pseudo Promise.all() polyfill

A few years back I interviewed with a company for a Javascript position. After a couple of warm-up challenges I was presented with this: Please write a function that calls back with ...
2
votes
1answer
86 views

Fetch: how to deal with a json payload in an error response?

Trying to get https://github.com/github/fetch working with an API that almost always returns a json payload, even when the response is an error: ...
0
votes
0answers
36 views

Javascript / Promises

I'm working on converting a simple Python script into nodejs 4.4.5 with es6 features like Promises. The original Python script did the following: Contact a 3rd party SOAP service Attempt to ...
0
votes
0answers
20 views

Promisify NodeJS and Mongose callback even further

I've recently started to experience writing Node.js code, and JavaScript in general. Right now I am planning to promisify (with Q) some of the node.js callback code I had, and I come to this. The ...
0
votes
0answers
55 views

Register a node-client code through an API call efficiently?

I've got a node_module that reads ArcValues for a user and updates the config of the node client at user's local (root). Like so: ...
4
votes
1answer
93 views

Javascript promises, multiple api calls in then()

This is the first time I'm trying to use promises in JavaScript so I'm not sure if I have done it correctly but it seems to work. The problem is that I have ended up with a "nested when" and it doesn'...
2
votes
0answers
29 views

Wrapping a node.js module

I need to use elasticseach in my node.js project, whose API looks like the following: ...
0
votes
1answer
69 views

ES6 Promise with the “co” module

I was trying to use the ES6 Promise with the "co" module to write the async code without callback. Though actual async call is neat and clean, I still have to add ...
-2
votes
1answer
40 views

Code Sample - promise chain / Angular

I am putting together a couple code samples for prospective employers and would love some feedback. I am still pretty junior so I am not sure what constitutes a good code sample and the do's and dont'...
1
vote
1answer
100 views

Check if images are loaded (ES6 Promises)

I wrote a small function that checks if an image or multiple images are loaded. For that purpose, I decided to use ES6 promises, but I'm not really sure if my way of handling errors is the best way. <...
0
votes
0answers
45 views

Iterating promise objects using generators

For the below code, ...
1
vote
0answers
22 views

Getting data from service and storing it in MongoDB

I wrote code to get data from HTTP service and store it in MongoDB. Please, can someone let me know how efficient my code is and whether it is good from the OOP point of view? ...
5
votes
0answers
64 views

Prevent multiple async calls from all attempting to refresh an expired OAuth token

I have some code that needs to access an API that requires OAuth authorization in the form of a token, and every time the token expires, it needs to be refreshed. I made a function called ...
4
votes
1answer
53 views

Conditional async validation function

We have the following validation function: ...
2
votes
1answer
192 views

Using fetch() and a new Promise object to get API results

I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected promise with an error subclass. I'm pretty new to both ES6 and Promises, ...
2
votes
1answer
71 views

Promise.spread “Polyfill”

I have written this "Polyfill" for Chrome's Promise object and I have some concerns about the implementation; Does it actually work as designed? It seems to work ...
1
vote
0answers
58 views

Recursion into git diff tree using nodegit

I'm using nodegit to develop the backend for a nodejs app that uses a mix of mongodb and git for persistence. The app has to version documents and be able to present diffs between versions, thus the ...
1
vote
1answer
45 views

Callback of setTimeout function when performing synchronous actions

Inside a function I'm calling playgame service. Once I've obtained the needed data (gameBeingPlayed), I need to show a 3..2..1 counter and then start a game. ...
2
votes
1answer
23 views

Parallel computation to be merged, depending on single call

Steps: Get AMOUNT from a call to API endpoint /a, e.g. AMOUNT == 5 (in the code it is set ...
2
votes
1answer
63 views

Asynchronous database lookups in Node.JS using Promises

Not confident enough if this would be the correct 'node way' of writing Promises: Essentially, there are two async database calls, the result from both of these ...
3
votes
1answer
78 views

Chain of promises

Often I end up with ...
4
votes
0answers
117 views

Bill has a hard time keeping all his promises

A couple days ago I created this Angular 1.x provider for my Ionic/Cordova app. I'm using webpack and babel-loader for ES6/ES2015 syntax and modules. All my provider does is "provide" an alternative ...
0
votes
0answers
274 views

Bluebird promises: generalized retry logic with timeout

I'm attempting to write an idiomatic utility that uses bluebird promises to retry asynchronous logic until it is successful, or until a set timeout expires. Currently I'm looking at: ...
1
vote
1answer
133 views

Handle API timeouts in Node Sails.js

I am working on a node.js sails.js app that handles a number of API calls and uses Bluebird for promises. The API calls have been reliable but I would like to build in handling for if they do not ...
2
votes
1answer
91 views

Probe for open application on a TCP port

I need to examine an application port to see if it opens and I need to put the retry count as a parameter. Since I'm new to Node I wanted to get your feedback on it for improvements. ...
3
votes
1answer
115 views

Loading a database table using a promise chain

I am creating a util module that I'm using to communicate with a MS-SQL database. I want each public method to return a promise. I started with a private function that executes a DB query and returns ...
4
votes
3answers
241 views

Performing data transportations in RxJS with Promises

I'm using RxJS 5.0.0-alpha.12 to perform some data transformations, and some of those transformations use Promises. ...
7
votes
1answer
452 views

Sails.js controller method for an admin to update a user account

I am new to Sails.js, Node.js, and web application development in general. My current understanding is that well-written controllers should be "skinny" meaning they should be as simple as possible, ...
4
votes
2answers
42 views

Promises turning into pyramids

I'm using node-ftp to download some files from an FTP server; due to nodeback difficulty and nested calls I'm promisified some of the calls, hoping that this will help get me out of pyramid code hell, ...
6
votes
1answer
291 views

A simple weather app in Node.js

while practicing Promises, I ended up with a simple weather application which works on the command line. I would highly appreciate it if you can point out any flaws ...
0
votes
2answers
59 views

Anti-pattern or acceptable way of using Promises? [closed]

Whenever I need to use a Promise interface in my NodeJs code and I don't have a promise to start off with, I do this: ...
4
votes
2answers
326 views

Bluebird: promisify xhr request

I use bluebird promises. I want to promisify my requests from communication layer: Utils.js ...
2
votes
1answer
26 views

Async db repository

This is a simple repository where I want to save all the invoices of some queried users. I wanted this module to only expose a simple saveInvoices method and return ...
0
votes
1answer
706 views

Access resolve function outside of a JavaScript Promise

I have an object that needs to have a single point of initialization, and other callers need to wait until the initialization is complete before continuing. I have done this with jQuery, and it feels ...
4
votes
2answers
811 views

Promises with NodeJS and BlueBird

I'm using bluebird for promises in my Node/Express application and wrote an API call in which the user passes in a JSON Web Token that contains their user ...
2
votes
3answers
123 views

Save handler without a nested “deferred antipattern”

I have an application in which a user makes a change, and when they click Save they will be prompted to confirm, and the appropriate REST call will be made if they agree. The intial call to ...
2
votes
0answers
560 views

Flux & async communication with websockets

I want to arrange async server-client communication with websockets and vanilla flux architecture. There is an excellent article about "Async Server-Side Communication with the Flux Architecture". I ...
1
vote
1answer
90 views

File existence promise

I hate to have to write a custom exists promise every time I need to know if a file exists, so I came up with this. Thoughts? ...
5
votes
1answer
158 views

Deleting a section of a website using Ajax

I am currently writing a decent amount of ajax to help me delete a section of a website. It's already becoming a pretty big piece of code, I wondered if it were possible to compact a section of my ...
1
vote
0answers
37 views

Making all directories to a path

Below are two promises: the first does a bit of nesting and the second is all anon then calls that return one function in them. Which do you prefer? Any improvements? Promise A: ...
1
vote
0answers
41 views

Chain-able promise file system functions

I'm trying to invent an easier way of working with the file system. Here I chain promise methods together. ...
1
vote
0answers
27 views

Find specific promise in array that contains both resolved and rejected values

I basically want to find a specific promise in a given array of promises. The thing is that (I'm using bluebird promises, but the same hold true for anouther standard implementations): it is ...