UNPKG

@ionic-native/network

Version:

Ionic Native - Native plugins for ionic apps

75 lines (70 loc) 2.94 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); var core$1 = require('@angular/core'); var core = require('@ionic-native/core'); var rxjs = require('rxjs'); var operators = require('rxjs/operators'); exports.Connection = void 0; (function (Connection) { Connection["UNKNOWN"] = "unknown"; Connection["ETHERNET"] = "ethernet"; Connection["WIFI"] = "wifi"; Connection["CELL_2G"] = "2g"; Connection["CELL_3G"] = "3g"; Connection["CELL_4G"] = "4g"; Connection["CELL"] = "cellular"; Connection["NONE"] = "none"; })(exports.Connection || (exports.Connection = {})); var Network = /** @class */ (function (_super) { tslib.__extends(Network, _super); function Network() { var _this = _super !== null && _super.apply(this, arguments) || this; /** * Constants for possible connection types */ _this.Connection = { UNKNOWN: 'unknown', ETHERNET: 'ethernet', WIFI: 'wifi', CELL_2G: '2g', CELL_3G: '3g', CELL_4G: '4g', CELL: 'cellular', NONE: 'none', }; return _this; } Network.prototype.onChange = function () { var _this = this; return (function () { if (core.checkAvailability(_this) === true) { return rxjs.merge(_this.onConnect().pipe(operators.mapTo('connected')), _this.onDisconnect().pipe(operators.mapTo('disconnected'))); } })(); }; Network.prototype.onDisconnect = function () { return core.cordova(this, "onDisconnect", { "eventObservable": true, "event": "offline", "element": "document" }, arguments); }; Network.prototype.onConnect = function () { return core.cordova(this, "onConnect", { "eventObservable": true, "event": "online", "element": "document" }, arguments); }; Object.defineProperty(Network.prototype, "type", { get: function () { return core.cordovaPropertyGet(this, "type"); }, set: function (value) { core.cordovaPropertySet(this, "type", value); }, enumerable: false, configurable: true }); Object.defineProperty(Network.prototype, "downlinkMax", { get: function () { return core.cordovaPropertyGet(this, "downlinkMax"); }, set: function (value) { core.cordovaPropertySet(this, "downlinkMax", value); }, enumerable: false, configurable: true }); Network.pluginName = "Network"; Network.plugin = "cordova-plugin-network-information"; Network.pluginRef = "navigator.connection"; Network.repo = "https://github.com/apache/cordova-plugin-network-information"; Network.platforms = ["Amazon Fire OS", "Android", "Browser", "iOS", "Windows"]; Network.decorators = [ { type: core$1.Injectable } ]; return Network; }(core.IonicNativePlugin)); exports.Network = Network;