Tagged Questions
6
votes
1answer
90 views
Is this a good approach to loading JavaScript files asynchronously?
I want to load JS files asynchronously to speed up page loading, but also need to execute JS code only once the scripts finish loading (so I need a way to implement callbacks).
I based this off of ...
5
votes
1answer
200 views
Load JSON file into model using Javascript / jQuery (deferred, asynchronous)
As a beginner I am always determined to improve myself. I've got written the following Code using jQuery that is working fine. However, I am sure that there are cleaner ways for achieving the same.
...
5
votes
1answer
5k views
Loading JavaScript files asynchronously
I need to get some scripts from the different social networking site and cache them. I want the function to be asynchronous, and non-blocking.
I have settled with a script, but I am not really sure ...
5
votes
1answer
84 views
Minimal but complete AMD implementation
I've got a minimal implementation (under 2k minified) of the Asynchronous Module Definition API. So far it handles all of the required stuff (I think; it passes the relevant unit tests, anyway), and ...
5
votes
1answer
71 views
AngularFire Tic Tac Toe Game
I am building a Tic Tac Toe game with AngularJS and making it online playable with AngularFire. The Tic Tac Toe logic is all there so this question concerns Angularfire a little bit more. I want to ...
4
votes
2answers
400 views
Wait until all files are loaded asynchronously, then run code
I'm an experienced programmer but not too great at JavaScript so I'm looking to see if I'm doing this 'right'. I want to have several files loaded in (Ajax or really AJAJ) and, once loaded, run some ...
4
votes
2answers
2k views
Async, callbacks, and closures — am I doing it right?
After having spent a month or two trying to learn JavaScript, especially functional programming, async, and closures, I finally get it. But I don't know if I'm writing elegant code... Specifically, ...
4
votes
2answers
96 views
Refactoring asynchronous JS pre-rendering code
A few months ago I wrote this module but, coming back to it, I find it a bit hard to read and reason about. I want to ask community's opinion on whether this needs to be refactored, and how I could ...
3
votes
1answer
776 views
Node.js Async Callback Hell
Attempting to create a final array with data pulled from 3 functions. The first two functions have all the data but then the 3rd function needs to run looping through one of the fields from function 2 ...
3
votes
1answer
173 views
A little “infile” Asynchronous Module Definition
I like the modular aspect of AMDs (Asynchronous Module Definition; see this Stack Overflow reply) and it's quite neat to structure JS.
But I typically compile all my JS files into one JS file. ...
3
votes
1answer
290 views
Asynchronous lightweight JSON API
I am writing a lightweight JSON API, and I come from a PHP background, so I have some questions/reviews about async node.js code.
This is my code so far:
main.js
...
2
votes
2answers
122 views
Simple Deferred / Promise pattern in JavaScript
I've wrote a very simple implementation of Deferred / Promise pattern (inspired by jQuery's $.deferred) for my tiny project (which does not use jQuery)
It can ...
2
votes
2answers
225 views
Timer factory fn optimization
I use this Timer function quite a bit lately for all sorts of stuff,
and would appreciate if someone could review/analize/criticize/verify
and, of course, suggest things I can do to optimize it for ...
2
votes
1answer
227 views
Limiting Q promise concurrency in JavaScript
I wrote a helper to limit Q promise concurrency.
If I have a promise-returning function promiseSomething, writing
...
2
votes
1answer
62 views
nodejs grunt plugin using async module
I'm looking for some code review of my usage of async. Mainly why this does not work without the done = this.async() method and why I don't have to invoke 'done()' ...
2
votes
1answer
70 views
Cleaning up nested promises in Cloud function
I am writing the Cloud function for Parse whose purpose is to update my database with a provided array of data objects. The main problem are the nested promises, which doesn't look right. Any help ...
2
votes
1answer
68 views
How to simplify this promise-driven animation code?
Inspired by this question on StackOverflow I've attempted to code such animation, mostly to get some more practice with async, promises and Q.js. Here's what I got:
(Live demo)
...
2
votes
1answer
220 views
Am I using Q the right way or is there a better way to do what I'm doing?
I'm using Q to flatten out some callbacks in my unit tests and return a promise to mocha (which knows to wait until the promise is resolved before running the next test).
Originally I had this code:
...
1
vote
2answers
186 views
A server response written in node/express/mongodb: does this look right?
This is my very very very first attempt to write anything meaningful in node. The client side is a simple form that has login, workspace, and simply saves them onto the database. It would have been a ...
1
vote
1answer
661 views
Calling a function when all asynchronous calls complete
Below is a simplified version of some code I am using to execute a function after all asynchronous calls complete. Is this a reasonable piece of code? It seems to work. Nothing would break if ...
1
vote
1answer
154 views
Best way to handle the error in async node
To catch errors, I have written if-else blocks in every function which looks bad. Please suggest a better way to handle errors in async node.
...
1
vote
1answer
560 views
Node.js DynamoDB callback
I am writing an API which gets results from a DynamoDB table and puts the JSON back into the browser.
The code below works and returns the desired results. However, after reading about async and ...
1
vote
1answer
227 views
Is this factory method a good approach?
We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a ...
1
vote
1answer
910 views
Simple Telnet Chat Server nodejs (correct way to write programs in node.js (asynchronous programming model))
I am new to node.js and asynchronous programming and this is my first small project to learn it. I have written a small Telnet Chat server and the program works but I want to know if this is the ...
1
vote
2answers
60 views
1
vote
1answer
1k views
Node.js Nested Callbacks, multiple requests
I'm making requests to Parse.com to 3 different objects that are needed to render a View.
I'd like to know what's the general/best approach in cases like these in which there are multiple requests ...
1
vote
0answers
52 views
Paginated Backbone.Collection subclass
This is a subclass of Backbone.Collection with a method fetchNextPage that returns a Q promise.
To find out the next page's ...
1
vote
0answers
812 views
Javascript Queue for async functions
Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually ...
0
votes
1answer
42 views
Processing a collection of objects, one at a time, with an asynchronous method.
I currently use setInterval and a wait flag to process this collection. Is there a cleaner way?
...