我有一个带有视频播放器的模板。它使用助手从 mongo 文档中获取视频源。这是它的样子:
帮手:
'currentItemUrl' : function() {
//I only have one project. Is there a better/cleaner way to obtain it than the one below?
var currentProject = Projects.find().fetch()[0];
//the function below will create an instance of videojs or update the current one (set the new source)
loadPlayer();
//I return the source url if I have one
return currentProject.setup.player.item_loaded.url?currentProject.setup.player.item_loaded.url:"";
}
HTML 看起来像这样:
<video id="video_player" class="video-js vjs-default-skin" controls preload="auto"
width = "{{videoWidth}}" height="videoHeight"
poster="{{currentItemPoster}}">
<source id="mp4" src="{{currentItemUrl}}" type='video/mp4' />
<source id="webm" src="" type='video/webm' />
<source id="ogg" src="" type='video/ogg' />
</video>
问题
Projects
当我在另一个模板中更新我的集合时,如何确保我的助手重新运行?既然我使用了 a Collection.find()
,它不应该已经是反应性的了吗?