问题描述
我遇到了 Meteor,虽然看起来很令人兴奋,但我想知道它是如何工作的.我的意思是传统的 Web 应用程序是这样工作的:您在服务器上有脚本,它们从数据库中获取数据并将其动态添加到网页中,用户提交的数据通过其他一些脚本添加到数据库中.
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.
但是这些东西在 Meteor 中是如何工作的呢?Meteor 的不同部分是如何相互关联的?
But how do these things work in Meteor? How are different parts of Meteor related to each other?
推荐答案
Meteor 是一个优雅地更新 HTML 的框架实时.
Meteor is a framework that elegantly updates HTML in realtime.
Meteor 的美妙之处在于您只需要创建模板和数据模型.其余的常规样板代码被隐藏起来.您无需编写所有同步代码.
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.
Meteor 的关键部分可以使用这些部分自己构建:
The key pieces of Meteor could be built yourself using these pieces:
它提供了模板,可在您的数据模型更新时自动更新.这通常使用 Backbone.js、Ember.js、Knockout.js 或其他工具.
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.
客户端/服务器消息是通过websockets 使用类似 socks.js 或 socket.io.
The client/server messaging is done via websockets using something like socks.js or socket.io.
客户端连接到 MongoDB 真的很酷.它将 MongoDB 服务器驱动程序复制到客户端.不幸的是,上次我检查时,他们仍在努力保护此数据库连接.
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.
您可以在 Meteor 网站或 在 GitHub 上.
There may be other neat pieces to that you can find on the Meteor site, or on GitHub.
这篇关于Meteor JavaScript 框架如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!