mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
@@ -17,7 +17,7 @@ export function onGetConnectionType(args: observable.EventData) {
|
||||
|
||||
export function onStartMonitoring(args: observable.EventData) {
|
||||
onGetConnectionType(null);
|
||||
connectivity.starMonitoring(onConnectionTypeChanged);
|
||||
connectivity.startMonitoring(onConnectionTypeChanged);
|
||||
}
|
||||
|
||||
export function onStopMonitoring(args: observable.EventData) {
|
||||
|
||||
@@ -30,7 +30,7 @@ export var test_DummyTestForSnippetOnly1 = function () {
|
||||
// <snippet module="connectivity" title="connectivity">
|
||||
// ### Monitoring connection type.
|
||||
// ``` JavaScript
|
||||
connectivity.starMonitoring(function onConnectionTypeChanged(newConnectionType: number) {
|
||||
connectivity.startMonitoring(function onConnectionTypeChanged(newConnectionType: number) {
|
||||
switch (newConnectionType) {
|
||||
case connectivity.connectionType.none:
|
||||
////console.log("Connection type changed to none.");
|
||||
|
||||
@@ -36,7 +36,7 @@ export function getConnectionType(): number {
|
||||
}
|
||||
}
|
||||
|
||||
export function starMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void {
|
||||
export function startMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void {
|
||||
var onReceiveCallback = function onReceiveCallback(context: android.content.Context, intent: android.content.Intent) {
|
||||
var newConnectionType = getConnectionType();
|
||||
connectionTypeChangedCallback(newConnectionType);
|
||||
|
||||
2
connectivity/connectivity.d.ts
vendored
2
connectivity/connectivity.d.ts
vendored
@@ -33,7 +33,7 @@ declare module "connectivity" {
|
||||
* Starts monitoring the connection type.
|
||||
* @param connectionChangedCallback A function that will be called when the connection type changes.
|
||||
*/
|
||||
export function starMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void;
|
||||
export function startMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void;
|
||||
|
||||
/**
|
||||
* Stops monitoring the connection type.
|
||||
|
||||
@@ -68,7 +68,7 @@ var _reachabilityCallbackFunctionRef = new interop.FunctionReference(_reachabili
|
||||
var _monitorReachabilityRef: any;
|
||||
var _connectionTypeChangedCallback: (newConnectionType: number) => void;
|
||||
|
||||
export function starMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void {
|
||||
export function startMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void {
|
||||
if (!_monitorReachabilityRef) {
|
||||
_monitorReachabilityRef = _createReachability();
|
||||
_connectionTypeChangedCallback = connectionTypeChangedCallback;
|
||||
|
||||
Reference in New Issue
Block a user