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

View File

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