本文整理汇总了TypeScript中connectivity.startMonitoring函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startMonitoring函数的具体用法?TypeScript startMonitoring怎么用?TypeScript startMonitoring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startMonitoring函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
return Observable.create((observer) => {
connectivity.startMonitoring((newConnectionType: number) => {
switch (newConnectionType) {
case connectivity.connectionType.none:
this.connectionType = "None";
observer.next('Connection type changed to none.');
break;
case connectivity.connectionType.wifi:
this.connectionType = "Wi-Fi";
observer.next('Connection type changed to WiFi.');
break;
case connectivity.connectionType.mobile:
this.connectionType = "Mobile";
observer.next('Connection type changed to mobile.');
break;
default:
break;
}
});
});
示例2: ngOnInit
ngOnInit() {
// >> connectivity-start-code
connectivity.startMonitoring((newConnectionType: number) => {
switch (newConnectionType) {
case connectivity.connectionType.none:
this.connectionType = "None";
console.log("Connection type changed to none.");
break;
case connectivity.connectionType.wifi:
this.connectionType = "Wi-Fi";
console.log("Connection type changed to WiFi.");
break;
case connectivity.connectionType.mobile:
this.connectionType = "Mobile";
console.log("Connection type changed to mobile.");
break;
default:
break;
}
});
// << connectivity-start-code
}
示例3: startMonitoring
startMonitoring(callback: { (connectionType: ConnectionType) }) {
return startMonitoring(callback);
}