mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
// >> connectivity-require
|
|
import * as connectivity from "tns-core-modules/connectivity";
|
|
// << connectivity-require
|
|
|
|
export var test_DummyTestForSnippetOnly0 = function () {
|
|
// >> connectivity-type
|
|
var connectionType = connectivity.getConnectionType();
|
|
switch (connectionType) {
|
|
case connectivity.connectionType.none:
|
|
//console.log("No connection");
|
|
break;
|
|
case connectivity.connectionType.wifi:
|
|
//console.log("WiFi connection");
|
|
break;
|
|
case connectivity.connectionType.mobile:
|
|
//console.log("Mobile connection");
|
|
break;
|
|
}
|
|
// << connectivity-type
|
|
};
|
|
|
|
export var test_DummyTestForSnippetOnly1 = function () {
|
|
// >> connectivity-monitoring
|
|
connectivity.startMonitoring(function onConnectionTypeChanged(newConnectionType: number) {
|
|
switch (newConnectionType) {
|
|
case connectivity.connectionType.none:
|
|
//console.log("Connection type changed to none.");
|
|
break;
|
|
case connectivity.connectionType.wifi:
|
|
//console.log("Connection type changed to WiFi.");
|
|
break;
|
|
case connectivity.connectionType.mobile:
|
|
//console.log("Connection type changed to mobile.");
|
|
break;
|
|
}
|
|
});
|
|
//...
|
|
connectivity.stopMonitoring();
|
|
// << connectivity-monitoring
|
|
};
|