本文整理匯總了TypeScript中meteor/meteor.Meteor.status方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meteor.status方法的具體用法?TypeScript Meteor.status怎麽用?TypeScript Meteor.status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類meteor/meteor.Meteor
的用法示例。
在下文中一共展示了Meteor.status方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: reconnect
reconnect() {
let server = ConnectServiceMeteor._getServerURL();
let display = server.result + (server.fromMeteor ? ' (url calculated by meteor)' : ' (url from config)');
console.info('Reconnecting: ' + display + ' Meteor.status(): ' + JSON.stringify(Meteor.status()));
Meteor.connect(server.result);
Meteor.reconnect();
}
示例2: switch
Tracker.autorun(() => {
const ddpStatus = MeteorMeteor.status && MeteorMeteor.status();
if(ddpStatus) {
this.statusString = ddpStatus.status;
switch (ddpStatus.status) {
case 'connected':
this.status = StatusEnum.connected;
break;
case 'connecting':
this.status = StatusEnum.connecting;
break;
case 'failed':
this.status = StatusEnum.failed;
break;
case 'waiting':
this.status = StatusEnum.waiting;
break;
case 'offline':
this.status = StatusEnum.offline;
break;
default:
this.status = undefined;
break;
}
this.connected = ddpStatus.connected;
this.retryCount = ddpStatus.retryCount;
} else {
this.status = StatusEnum.offline;
this.connected = false;
this.retryCount = 0;
}
});
示例3: isConnected
async isConnected():Promise<boolean> {
return await Meteor.status().connected;
}