Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools




  • meteor 的 helpers 有一些能自动更新,有一些不能,具体原因及自动更新的方法可参考
  • 命名规范
    • 主要用 camelCase
    • 文件名用下划线 my_file.js
    • CSS 用连字符 .my-class
  • 部署到服务器可以
    • 用 meteor 命令部署到 meteor 服务器
      $ meteor deploy myapp.meteor.com
    • arunoda/meteor-up 部署到自架服务器
  • meteor 页面加载后,会打开一条 websocket 的通信,处理 isClient 中对 DB 的请求等
  • websocket 的通信用 firebug ⇐ 2.0.4 看不了,用 chrome >= 38.0 可以
    • Network → filter websockets → 点开一个 websocket → 点开其 frames 页,可以查看到
    • 但是该页不能自动刷新,想看新请求,得点 headers 再点回去才行
  • meteor 的 templating system 叫 spacebars,主要有 3 个 features
    • Inclusions/partials use the {{> templateName}}
    • Expressions such as {{title}}
    • Block helpers such as {{#each}}…{{/each}} or {{#if}}…{{/if}}
      • The {{#each}} block helper not only iterates over our array, it also sets the value of this inside the block to the iterated object.
  • 文件上传
  • ubuntu 不配置 utf8 export LC_ALL=en_US.UTF-8 无法启动 Meteor Mongodb exit code 1, Restarting. #4019
  • 不支持 node 0.12 Support Node 0.12
  • 小内存(512 mb)无法启动 ERR NOMEM,meteor 至少占 200 mb 内存


meteor 对一些常用模块提供了自己的管理方法:

# 列出模块
$ meteor list
# 安装模块
$ meteor add bootstrap
$ meteor add accounts-ui accounts-password

Seven Principles of Meteor

  • Data on the Wire.
    Don't send HTML over the network. Send data and let the client decide how to render it.
  • One Language.
    Write both the client and the server parts of your interface in JavaScript.
  • Database Everywhere.
    Use the same transparent API to access your database from the client or the server.
  • Latency Compensation.
    On the client, use prefetching and model simulation to make it look like you have a zero-latency connection to the database.
  • Full Stack Reactivity.
    Make realtime the default. All layers, from database to template, should make an event-driven interface available.
  • Embrace the Ecosystem.
    Meteor is open source and integrates, rather than replaces, existing open source tools and frameworks.
  • Simplicity Equals Productivity.
    The best way to make something seem simple is to have it actually be simple. Accomplish this through clean, classically beautiful APIs.


database everywhere

  1. meteor 从 server 传给 client 的是数据,而非渲染好的网页。传数据的好处包括
    1. 由 client 端决定如何渲染数据
    2. client 端可修改数据
  2. server 端可只 publish 一部分数据给 client,以保证安全
  3. client 可只要求部分数据,以节省浏览器内存
    // on the server
    Meteor.publish('posts', function(author) {
      return Posts.find({flagged: false, author: author});
    // on the client
    Meteor.subscribe('posts', 'bob-smith');
  4. client 在拿到部分数据后,还可接着做 find(不过加载到内存的已经是所有 bob 的数据了)
    // on the client
      posts: function(){
        return Posts.find({author: 'bob-smith', category: 'JavaScript'}); 
it/meteor.txt · Last modified: 2015/07/27 10:20 by admin