doc(barcode-scanner): optimize example code

This commit is contained in:
Daniel Sogl 2018-03-16 14:19:16 +01:00 committed by GitHub
parent f11be24f74
commit 1546cec694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,7 @@
import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface BarcodeScannerOptions {
/**
* Prefer front camera. Supported on iOS and Android.
*/
@ -52,11 +51,26 @@ export interface BarcodeScannerOptions {
* Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
*/
resultDisplayDuration?: number;
}
export interface BarcodeScanResult {
format: 'QR_CODE' | 'DATA_MATRIX' | 'UPC_E' | 'UPC_A' | 'EAN_8' | 'EAN_13' | 'CODE_128' | 'CODE_39' | 'CODE_93' | 'CODABAR' | 'ITF' | 'RSS14' | 'RSS_EXPANDED' | 'PDF417' | 'AZTEC' | 'MSI';
format:
| 'QR_CODE'
| 'DATA_MATRIX'
| 'UPC_E'
| 'UPC_A'
| 'EAN_8'
| 'EAN_13'
| 'CODE_128'
| 'CODE_39'
| 'CODE_93'
| 'CODABAR'
| 'ITF'
| 'RSS14'
| 'RSS_EXPANDED'
| 'PDF417'
| 'AZTEC'
| 'MSI';
cancelled: boolean;
text: string;
}
@ -77,10 +91,10 @@ export interface BarcodeScanResult {
* ...
*
*
* this.barcodeScanner.scan().then((barcodeData) => {
* // Success! Barcode data is here
* }, (err) => {
* // An error occurred
* this.barcodeScanner.scan().then(barcodeData => {
* console.log('Barcode data', barcodeData);
* }).catch(err => {
* console.log('Error', err);
* });
* ```
* @interfaces
@ -96,7 +110,6 @@ export interface BarcodeScanResult {
})
@Injectable()
export class BarcodeScanner extends IonicNativePlugin {
Encode: {
TEXT_TYPE: string;
EMAIL_TYPE: string;
@ -117,7 +130,9 @@ export class BarcodeScanner extends IonicNativePlugin {
@Cordova({
callbackOrder: 'reverse'
})
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> { return; }
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
return;
}
/**
* Encodes data into a barcode.
@ -127,6 +142,7 @@ export class BarcodeScanner extends IonicNativePlugin {
* @returns {Promise<any>}
*/
@Cordova()
encode(type: string, data: any): Promise<any> { return; }
encode(type: string, data: any): Promise<any> {
return;
}
}