You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
630 B
24 lines
630 B
import {
|
|
invoke
|
|
} from 'uni-core/service/bridge'
|
|
|
|
import {
|
|
onMethod
|
|
} from '../../platform'
|
|
|
|
function on (method) {
|
|
const callbacks = []
|
|
onMethod(method, data => {
|
|
callbacks.forEach(callbackId => {
|
|
invoke(callbackId, data)
|
|
})
|
|
})
|
|
return function (callbackId) {
|
|
callbacks.push(callbackId)
|
|
}
|
|
}
|
|
|
|
export const onBluetoothDeviceFound = on('onBluetoothDeviceFound')
|
|
export const onBluetoothAdapterStateChange = on('onBluetoothAdapterStateChange')
|
|
export const onBLEConnectionStateChange = on('onBLEConnectionStateChange')
|
|
export const onBLECharacteristicValueChange = on('onBLECharacteristicValueChange')
|
|
|