Here’s a little bit of CoffeeScript, but feel free to answer in JavaScript: Elsewhere, a view is listening for the add event on the collection: Sometimes the model hadn’t finished talking to the server, so it didn’t have an id and this code failed to do what was wanted. So, I wrapped the save in a promise using the when.js
Tag: promise
socket.io – socket.on wait for promise
I have a button that does some communication with the server to check if an entered value (via an input box) already exists. The code is the following: The problem is that the checkReturn call is asynchronous, and therefore the code carries on without actually waiting for the result. How do I make sure that checkReturn is first finished and
What happens if i reject / resolve multiple times in Kriskowal’s q?
I’m studying the promises pattern and using kriskowal’s q for node.js, having this snippet: What if both the parser fails and some_reason is true? Will the execution procede from rejecting through resolving and both promise’s method be called at different times, thus generating a bug? Should i avoid to call reject/resolve multiple times? Answer Since promises can only resolve once