-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
34 lines (28 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const ReactNative = require('react-native')
const { NativeModules, DeviceEventEmitter } = ReactNative
const HoneywellBarcodeReader = NativeModules.HoneywellBarcodeReader || {} // Hacky fallback for iOS
/**
* Listen for available events
* @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
* @param {Function} handler Event handler
*/
var subscriptionBarcodeReadSuccess = null
var subscriptionBarcodeReadFail = null
HoneywellBarcodeReader.onBarcodeReadSuccess = (handler) => {
subscriptionBarcodeReadSuccess = DeviceEventEmitter.addListener(HoneywellBarcodeReader.BARCODE_READ_SUCCESS, handler)
}
HoneywellBarcodeReader.onBarcodeReadFail = (handler) => {
subscriptionBarcodeReadFail = DeviceEventEmitter.addListener(HoneywellBarcodeReader.BARCODE_READ_FAIL, handler)
}
/**
* Stop listening for event
* @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
* @param {Function} handler Event handler
*/
HoneywellBarcodeReader.offBarcodeReadSuccess = () => {
subscriptionBarcodeReadSuccess.remove()
}
HoneywellBarcodeReader.offBarcodeReadFail = () => {
subscriptionBarcodeReadFail.remove()
}
module.exports = HoneywellBarcodeReader