Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Basically I'm writing an app and am using Sails, MongoDB and Node JS for the back end. I'll use Sail's API features and was wondering what would be the best way to make the app realtime.

For instance I could use AJAX to call the API and manipulate the DOM using jQuery and update the DB through $.post then let the model update the db in the backend, however I'm finding this approach quite cumbersome. Not to mention I can see the code could become quite difficult to maintain after a while.

I've been doing some research and - if I understood correctly - it seems I could use either Backbone, Angular or Knockout to manipulate the data/DOM on the front end, however I'm not sure what would be the best approach in my case nor whether any of these would indeed suit my needs:

  • Being able to get the data dynamically
  • Update the data and the DOM dynamically as the user interact with the page
  • Post the updated data dynamically with none or as minimal data transformation on the back end as possible
  • All the above asynchronously

As I don't want this to become a heated debate on which library is best, so I would like to know only whether any of the aforementioned libraries can do what I need and which is the leanest/simplest/has the lighter learning curve.

share|improve this question
1  
find one you like todomvc.com –  charlietfl 23 hours ago
 
"One page" sites with front end updates are overrated IMO. I see websites everyday that don't work and have failed miserably in applying this, and where regular pageloads would have been so much better. Unless you know what you're doing and can get it working flawlessy, or you really need a site where everything updates dynamically, I don't see the point. Keeping static resources to a minimum and using Node your pageloads will be so fast that users normally wont even notice. On the other hand, there's nothing wrong with using ajax or sockets for dynamic content and asynchronous functionality. –  adeneo 23 hours ago
 
This question is too broad and too opinion based and as such isn't a good match for StackOverflow as written. If you had a specific programming question and wanted to understand details about how it worked or compared to another option, that would be a better question. –  WiredPrairie 23 hours ago

2 Answers

up vote 0 down vote accepted

I did similar research a while ago and when found AngularJS, just stopped looking any further.

Right to your questions:

Being able to get the data dynamically

It is pure pleasure to do it in Angular. For the very basic functionality you have got $http service which allows you to send http request and register a callback when the data arrives. For more complicated things there are modules ngResource and Restangular (external).

Update the data and the DOM dynamically as the user interact with the page

For manipulating DOM, Angular introduced concept of directive. It is basically future of the web (Shodow DOM and Web Components) right now. At this time point, there is nothing more elegant out there.

Post the updated data dynamically with none or as minimal data transformation on the back end as possible

Yes. JSON.

All the above asynchronously.

Yes, of course.

share|improve this answer

SailsJS provides interchangeability of HTTP or socket.io connections. In your case I think sockets would be a better fit than AJAX.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.