【发布时间】:2013-10-26 04:41:05
【问题描述】:
我有一个订阅 4 个集合的应用程序(每个集合非常小,只有 1 到 20 条记录)。但是加载这些集合所花费的时间是巨大的。 其中一个只有 13 条记录,加载它的模板需要几秒钟。正常吗? (我还在流星服务器上测试)
这是代码示例:
Meteor.subscribe('trackedUser', function() {
console.log('finished fetching trackedUser');
Template.users.rendered = function() {
/*handlign of the template*/
console.log('users template rendered');
}
});
/*observe geolocation after it is all fetched*/
Meteor.subscribe('geolocation', function() {
console.log('finished fetching location');
/* Obseve the Collection geolocation and trigger event when item inserted or removed */
query = Geolocation.find({});
query.observeChanges({
added: function(id) {
addMarkerToMap(id);
window.map.fitBounds(group.getBounds());
return;
}
});
});
});
这是我的模板
<template name="users">
<ul id="item-list">
{{#each trackedUser}}
<li id="{{_id}}">
<input type="checkbox" checked />
<span><select name="colorpicker">
{{#each color}}
<option value="{{mColorCode}}" {{selected ../mColor mColorCode}}>{{mColorName}}</option>
{{/each}}
</select>
</span>
<img width="40" src="data:image/png;base64,{{mImage}}" />
<span class="name">{{mUsername}}</span>
<p><span class="description">{{mDescription}}</span></p>
</li>
{{/each}}
</ul>
</template>
谢谢
【问题讨论】:
-
你有应用部署到meteor.com吗?你会分享网址吗?
-
根据我的经验,
subdomain.meteor.com很慢。他们可能有 1 台服务器托管 500 个演示站点。在本地测试时是否也一样慢?
标签: collections meteor