2012-06-29 46 views
7

誰能告訴我爲什麼在這個例子中呈現的Live HTML保持清除,然後在無限循環中重繪?此示例代碼馬克塞斯的CPU在我的筆記本..模板不斷重繪,儘管底層數據沒有變化

環境:

  • 流星0.3.7
  • 的Mac OS獅子
  • 在Safari 5.1.7測試版本的Chrome Canary 22.0.1189, Chrome瀏覽器21.0.1180,火狐11.0 & 13.0

初始創建項目:

meteor create test 
cd test 
meteor add coffeescript 
mv test.js test.coffee 
meteor 

test.coffee:

Records = new Meteor.Collection("records") 

if Meteor.is_client 
    Template.table.records = -> 
     Records.find() 
    Template.table.rowCount = -> 
     Records.find().count() 

if Meteor.is_server 
    Meteor.startup -> 
     if Records.find().count() is 0 
      for i in [1..1000] 
       Records.insert({some:"test", data: "just", to: "check"}) 

的test.html:

<head> 
    <title>test</title> 
</head> 

<body> 
    {{> table}} 
</body> 

<template name="table"> 
    <table> 
     <caption>{{rowCount}}</caption> 
     {{#each records}} 
     <tr> 
      <td>{{some}}</td> 
      <td>{{data}}</td> 
      <td>{{to}}</td> 
     </tr> 
     {{/each}} 
    </table> 
</template> 
+1

我運行了具有不同數據集大小的相同示例代碼:重繪問題似乎與設置超過800個記錄的集合一起出現.. – Lloyd

+1

我已將其移入Meteor問題跟蹤器。 https://github.com/meteor/meteor/issues/207 – steveluscher

+0

是的,我注意到,感謝那個史蒂夫 – Lloyd

回答

-1

嘗試升級流星。我剛剛在當前的主文件中嘗試了這個確切的示例代碼(在編寫0.5.2時)。我在所有的Chrome,Firefox和Safari中打開了頁面,並且我的CPU使用率很低。

+0

它仍然是一個開放的問題https://github.com/meteor/meteor/issues/207 – Lloyd