Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the Meteor JavaScript framework work? [closed]

I came across Meteor and while it seems exciting, I want to know how it works. I mean conventional web applications work like this: You have scripts on server which take data from database and add that dynamically to web-pages and the user-submitted data gets added to databases through some other scrips.

But how do these things work in Meteor? How are different parts of Meteor related to each other?

like image 530
Jatin Avatar asked Apr 18 '12 17:04

Jatin


People also ask

How does MeteorJS work?

Meteor uses data on the wire, meaning the server sends data, not HTML, and the client renders it. Meteor embraces the ecosystem, bringing the best parts of the extremely active JavaScript community to you in a careful and considered way.

Is MeteorJS a framework?

MeteorJS is a do-it-all framework for making JavaScript applications.

Is Meteor front-end or backend?

Meteor gives you data management solution across client and server, and React gives you a way to structure your app's UI from reusable components. Meteor can complement AngularJS by providing back-end code simple enough for front-end developers to use.

Is Meteor a good framework?

It is a great choice for developers-to-be, who would like to start learning programming, and for developers experienced in languages other than JavaScript, who would like to master JS as well. Most JS developers would say that Meteor is one of the easiest (if not the easiest) framework to learn.


2 Answers

Meteor is a framework that elegantly updates HTML in realtime.

The beauty of Meteor is that you only need to create the templates and the data models. The rest of the usual boilerplate code is hidden away. You don't need to write all the sync-ing code.

The key pieces of Meteor could be built yourself using these pieces:

  • It provides templating that updates automatically when your data models do. This is normally done using Backbone.js, Ember.js, Knockout.js, or another tool.

  • The client/server messaging is done via websockets using something like socks.js or socket.io.

  • The client side connection to MongoDB is really cool. It replicates the MongoDB-server driver into the client. Unfortunately, last I checked, they were still working on securing this database connection.

  • The latency compensation is simply updating the client-side model first, then sending the update to the server-server.

There may be other neat pieces to that you can find on the Meteor site, or on GitHub.

like image 117
xer0x Avatar answered Sep 22 '22 21:09

xer0x


Disclaimer: This answer describes Meteor, JavaScript client library for Meteor Server. It was originally added due to ambiguity in the question, and may serve the purpose of clarifying similar ambiguities faced by the visitors searching for similar answers, but unsure about the difference.

To read about Meteor JavaScript framework, please see this answer by xer0x.

As mentioned on the Meteor Server's documentation, Meteor is an implementation of Comet. Comet in turn is a counterpart of AJAX.

In case of AJAX, you usually make a request when the client sees a need to do that. To pull updates from the server, you will need to call the server eg. every 5 seconds.

In case of Comet, the update from the server comes faster, because the connection is persistent. The connection is established by client, as in AJAX, but the server does not respond until it has some update or it reaches execution limit (scripts on the server may have execution limits).

In case of Meteor you just get constant stream of data that needs some specific server-side code (like Meteor Server) and appropriate code on the client (in this case it looks like it is Meteor class).

like image 39
Tadeck Avatar answered Sep 18 '22 21:09

Tadeck