Writing Real-Time Applications with NodeJS

im looking forward to building RT web applications using NodeJS. Coming from Rails, I really enjoyed programming NodeJS and Async JS.

Run some experiments with Node, and then when I look for tools and resources I can get used to, I was overwhelmed with a lot of things there.

I found many libraries and components there, and was pretty much confused about how to create a large-scale, well-written and embedded RT web application.

Thus, the application will work through NodeJS using the Express framework.

I read about knockout.js , a client-side library, to provide real-time content such as automatic user interface updates, and I think I could combine it with jQuery. In addition, I found socket.io . The author says: Socket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It care-free realtime 100% in JavaScript. Socket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It care-free realtime 100% in JavaScript. Therefore socket.io is compatibility. What about backbone.js ? Where is he going?

With so many things, I was shocked. What should I learn? What modules need to be studied? Im focuses on NodeJS and Express, but most books / screencasts cover older versions of nodejs. Thus, I was guided by my official API. Now I am asking for advice and somehow somehow collected all the information. Correct me if my assumptions are not accurate, point me in the right direction and do not hesitate to suggest any other module that could help in my training.

Thanks in advance

+6
source share
2 answers

It may be useful for you to separate the libraries of third-party node.js servers (via npm, etc.) from all libraries and browsers on the client side (such as jquery, backbone, knockout, etc.) when you think about it. Even socket.io, which provides a permanent socket connection between the browser and the server (to avoid polling), does not determine which client-side technologies you use.

Focus on exhibiting a reliable web api ( random example ) from your server, and your client technologies can be replaced, supplemented, etc. without affecting the server. The only place where they intersect is to use viewing technology such as Jade. It is also an opportunity to have a clean separation, where the server simply serves the client files, and your client is a thicker javascript application (using knockout, jquery, etc.) that invokes a good server website.

Some people try to combine client and server models — for example, this article using backbone and node. It depends on how much data you work to say if this is possible, but it connects the client and server and makes it server-side, which may have flaws (scaling, affinity is required, etc.). Personally, I am wary of this magic (binding, state, synchronization, etc.). Node is to keep things simple, light and fast. It is a fast network server.

My 2 cents (and some may not agree). Start with Node on the server and select your repository (mongoDb, etc.). The design of a solid RESTful (hypermedia) API is a good webapi, regardless of the client. Then start with the basic html / css / js, possibly a jquery client, and add things like knockout, etc. when you expand your customer experience. This will allow you to replace your client technologies regardless of your server, as new technology winds change (and they will).

This is the hallmark of a well-designed system - the ability to replace components / subsystems without rewriting everything :)

Hope that helps clear up the fog :)

+7
source

You can watch Meteor if you focus on real-time Javascript applications: http://meteor.com/

0
source

Source: https://habr.com/ru/post/926172/


All Articles