我有一个订阅 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>
谢谢