refactor(network): remove Connection class

closes #278
This commit is contained in:
Ibby Hadeed 2016-07-11 17:15:34 -04:00
parent 9eb63a0d74
commit 6229d4932e
2 changed files with 6 additions and 22 deletions

View File

@ -51,7 +51,7 @@ import {Keyboard} from './plugins/keyboard';
import {LaunchNavigator} from './plugins/launchnavigator';
import {LocalNotifications} from './plugins/localnotifications';
import {MediaPlugin} from './plugins/media';
import {Network, Connection} from './plugins/network';
import {Network} from './plugins/network';
import {OneSignal} from './plugins/onesignal';
import {Printer} from './plugins/printer';
import {Push} from './plugins/push';
@ -107,7 +107,6 @@ export {
BLE,
BluetoothSerial,
Clipboard,
Connection,
DBMeter,
Deeplinks,
DeviceAccounts,
@ -158,7 +157,6 @@ window['IonicNative'] = {
Camera: Camera,
CardIO: CardIO,
Clipboard: Clipboard,
Connection: Connection,
Contacts: Contacts,
DatePicker: DatePicker,
DBMeter: DBMeter,

View File

@ -10,7 +10,7 @@ declare var navigator: any;
*
* @usage
* ```js
* import {Network, Connection} from 'ionic-native';
* import {Network} from 'ionic-native';
*
* // watch network for a disconnect
* let disconnectSubscription = Network.onDisconnect().subscribe(() => {
@ -28,8 +28,7 @@ declare var navigator: any;
*// before we determine the connection type. Might need to wait
* // prior to doing any api requests as well.
* setTimeout(() => {
* console.log(Network.connection);
* if (Network.connection === Connection.WIFI) {
* if (Network.connection === 'wifi') {
* console.log('we got a wifi connection, woohoo!');
* }
* }, 3000);
@ -39,6 +38,8 @@ declare var navigator: any;
* connectSubscription.unsubscribe();
*
* ```
* @advanced
* The `connection` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none`
*/
@Plugin({
plugin: 'cordova-plugin-network-information',
@ -52,7 +53,7 @@ export class Network {
* Return the network connection type
*/
@CordovaProperty
static get connection(): Connection { return navigator.connection.type; }
static get connection(): String { return navigator.connection.type; }
/**
* Get notified when the device goes offline
@ -75,18 +76,3 @@ export class Network {
static onConnect(): Observable<any> { return; }
}
/**
* @private
*/
export class Connection {
static get UNKNOWN() { return 'unknown'; }
static get ETHERNET() { return 'ethernet'; }
static get WIFI() { return 'wifi'; }
static get CELL_2G() { return '2g'; }
static get CELL_3G() { return '3g'; }
static get CELL_4G() { return '4g'; }
static get CELL() { return 'cellular'; }
static get NONE() { return 'none'; }
}