Javascript Meteor.status()不是被动数据源?
我们正在尝试执行以下操作以在应用程序上显示连接状态:Javascript Meteor.status()不是被动数据源?,javascript,angularjs,meteor,reactive-programming,angular-meteor,Javascript,Angularjs,Meteor,Reactive Programming,Angular Meteor,我们正在尝试执行以下操作以在应用程序上显示连接状态: this.helpers({ userBlock: () => { //... return { name: name, connectionStatus: Meteor.status().connected } } }); 但是,服务器断开连接后,助手不会重新运行。通过$scope和controller引用将Meteor.
this.helpers({
userBlock: () => {
//...
return {
name: name,
connectionStatus: Meteor.status().connected
}
}
});
但是,服务器断开连接后,助手不会重新运行。通过$scope和controller引用将
Meteor.status().connected
变量直接输出到模板中,也看不到其值更新。关于如何让助手使用Meteor.status().connected重新运行的任何想法?
更改?这就是我的实现方式,它按预期工作。当服务器关闭时,模板呈现“断开连接”消息,当服务器再次返回时,该消息消失
var SHOW_CONNECTION_ISSUE_KEY = 'showConnectionIssue';
Session.setDefault(SHOW_CONNECTION_ISSUE_KEY, false);
Meteor.startup(function () {
// Only show the connection error box if it has been 5 seconds since
// the app started
setTimeout(function () {
// Show the connection error box
Session.set(SHOW_CONNECTION_ISSUE_KEY, true);
}, 5000);
});
Template.header.helpers({
connected: function() {
if (Session.get(SHOW_CONNECTION_ISSUE_KEY)) {
return Meteor.status().connected;
} else {
return true;
}
}});
在模板中:
{{#unless connected}}
<div class="alert alert-danger">
Disconnected
</div>
{{/unless}}
{{{#除非连接}
断开的
{{/除非}